Skip to content

Commit

Permalink
add version to aasets for fix problems with browsers cache
Browse files Browse the repository at this point in the history
  • Loading branch information
vasiliishvakin committed Feb 20, 2018
1 parent e585b80 commit 8def341
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/AssetExtension.php
Expand Up @@ -346,12 +346,14 @@ public function processAssets($files, $filters = null, $debug = false)
$filePath = $asset->getSourceDirectory();
if (false !== $subDir = FileSystem::getSubDir($this->getPublicDir(), $filePath)) {
$subDir = !empty($subDir) ? $subDir . DIRECTORY_SEPARATOR : "";
$webPatches[] = $this->getWebPublic() . DIRECTORY_SEPARATOR . $subDir . basename($asset->getSourcePath());
$version = md5(filemtime($asset->getSourceDirectory(). DIRECTORY_SEPARATOR . $asset->getSourcePath()));
$webPatches[] = $this->getWebPublic() . DIRECTORY_SEPARATOR . $subDir . basename($asset->getSourcePath()) . '?v=' . $version;
} else {
$filePath = $this->writeAsset($asset);
$subDir = FileSystem::getSubDir($this->getOutputDir(), dirname($filePath));
$subDir = !empty($subDir) ? $subDir . DIRECTORY_SEPARATOR : "";
$webPatches[] = $this->getWebOutput() . DIRECTORY_SEPARATOR . $subDir . basename($filePath);
$version = md5(filemtime($filePath));
$webPatches[] = $this->getWebOutput() . DIRECTORY_SEPARATOR . $subDir . basename($filePath) . '?v=' . $version;
}
}

Expand Down

0 comments on commit 8def341

Please sign in to comment.