Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CSS and JS caching is defeated by URL parameters #28

Open
meyergru opened this issue Jan 8, 2017 · 2 comments
Open

CSS and JS caching is defeated by URL parameters #28

meyergru opened this issue Jan 8, 2017 · 2 comments

Comments

@meyergru
Copy link

meyergru commented Jan 8, 2017

I found that because the compressed resources are suffixed by a '?v=' parameter that has the file creation time, effectively resource caching is defeated.

Why is this? The name of the file is already made of the MD5 of the file content, so why is there another parameter which is not really used anyway? I assume you tried to defeat the resource caching if the file was modified, but in that case, the MD5 would differ anyway. By adding an URL parameter, nothing gets cached at all.

If I am correct, it would suffice to just remove the code lines where the '?v=' is added.

@skeeks-semenov
Copy link
Owner

Yes, this is done to clear the cache. And it need not be removed.

The logic is that under any scenario, checked md5 just from a set of files. If a single file is updated, the yii2 change it ?v=value and then md5 of the data set in the same change. This is easy to do and does not require the reading of all the files and comparing them md5 values.

https://github.com/skeeks-semenov/yii2-assets-auto-compress/blob/master/AssetsAutoCompressComponent.php#L353

@meyergru
Copy link
Author

meyergru commented Jan 8, 2017

Excuse me, my bad: I was wrong. Firefox did never cache the resources because of an obscure Apache bug with mod_deflate and mod_brotli explained here:

https://fullstackhack.wordpress.com/2014/12/10/the-pain-of-etags-mod_deflate-apache-2-4-and-tomcat-7/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants