-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Respect enable_asset_timestamp
settings for pipelined Assets
#906
Conversation
I think it's simply missing in that case, no real reason behind that. But it should also take in consideration the |
@flaviocopes That's a good point! I'll wait for @rhukster maybe he can shed some more light on it. Concerning the |
Here's the thing.. The timestamp was intended for regular assets links only. This is because if you have LONG timeouts or expires for style/js assets, the browser will not even ask for refreshed files unless the url changes somehow. A timestamp is enough to trigger this. For the pipeline, once created, the pipeline is not updated or regenerated no matter if a CSS/JS file is modified. So really the only way to force the regeneration is to clear the asset cache. However on regeneration, the filename is not going to change as it's a named based on md5 of the files involved. So even after regeneration, it might be cached or not even requested, hence the forced timestamp. Also, changing this behavior might have a negative effect on the behavior of existing sites. However, i have an idea for a solution:
This will ensure that every time the css/pipeline is regenerated, the name is unique and thereforce not going to be cached. The timestamp at the end will not really have much of an effect, but added merely for consistency and expected results. This probably will also fix the problems we see with CDN caching and not updating with just a |
Ok, I fully understand. Wasn't aware that the hash is based on the files involved. Thought it was somehow also derived from Grav cache key... But you are right (L677) and I really like your idea! :-D I have updated my PR. Hope you like it. |
Actually I don't think it should be the cache key, rather an actual time stamp of now |
looks good to me! |
After a good sleep, I don't think that having such a timestamp with |
Actually you are right, this won't work correctly because the file will be generated every time. We need a last generated timestamp that is actually stored in the |
i've switched it back to cache key for the time being so it will at least not recreate the pipeline everytime. |
I don't know if this is intentional, but the enabled
enable_asset_timestamp
settings is not respected for pipelined assets. Even if I disable this setting the cache key is always added.I know why the cache key should be present due to browser cache invalidation of changes. However what I don't understand is then, why this setting currently only affects non-pipelined assets (see e.g. Assets.php#L556).
This PR is for the lazy-man. Instead of opening an issue we can discuss it here or if this behavior is intentional, feel free to close it.