CodeSleeve / asset-pipeline

This Laravel 4 package provides a very simple and easy to use asset pipeline. It was heavily inspired by the Rails asset pipeline. We make use of the wonderful Assetic package to help with pre-compliation!
http://www.codesleeve.com
MIT License
489 stars 53 forks source link

Browser cache issues #223

Open kticka opened 9 years ago

kticka commented 9 years ago

How to avoid browser cache? When all css/js is concatenated, it generates 'application.css' and 'application.js' files, and then serve them to the browser. Concatenated file name is strictly related with manifest file, so if I want to change name of concatenated javascript file, I should change manifest file to. And I should do this in every deployment. There could be some option to pass concatenated file version or something like that and force browser to download new / updated javascript file.

RomainLanz commented 9 years ago

I think that the better way to do that is to add a hash of all file at the end of the name application.css and application.js like Ruby On Rails do.

EDIT :

I just read the code, and the hash on the file is already that I said.

public function generateCacheKey($path, $lastModified, $salt = '')
{
    return md5($path . $lastModified . $salt);
}

But, it's not write on the file which is send to the browser. Maybe add the key at the end?