protected function buildTypeCache($type, $files)
    {
        $typeContent = '';
        $fileHashs = array();

        // Generate the content for all the files
        foreach ($files as $file) {
            $fileName = $file->getFileName();
            if (!file_exists($fileName)) {
                continue;
            }

            // Load the content
            $content = $this->fileBackend->loadFromFile($fileName);
            
            // Optimze the content
            $content = $this->optimizeContent($type, $fileName, $content);
            
            // Add the content and save the file hash
            $typeContent .= $content;
            $fileHashs[$this->getHash($fileName)] = md5_file($fileName);
        }

        // Minify the content, if possible and activated
        if (($type === AssetManager::CSS || $type === AssetManager::JS) && $this->minifyAssets) {
            $typeContent = $this->minifyContent($type, $typeContent);
        }
        
        // Generate the hash and the new file name
        $hash = $this->getTypeHash($type);
        $version = $type . '-' . uniqid() . '.' . $this->getExtensionForType($type);
        $targetFile = $this->buildFilePath($type, $hash, $version);

        // Save the cached file
        $this->removeOldTypeCacheFile($type);
        $this->fileBackend->saveToFile($typeContent, $targetFile);

        // Save the cached files in the data array
        $this->cachedFiles[$hash] = array(
            'file' => $targetFile, 
            'checksums' => $fileHashs,
            'timestamp' => time()
        );
        $this->saveAssetsCache();
        
        return $targetFile;
    }