Uh oh!
There was an error while loading. Please reload this page.
Add Cache-control: immutable - #7904
Conversation
rullzer
commented
Jan 17, 2018
@MorrisJobke@nickvergessen@ChristophWurst@skjnldsv how do you all feel about this? It would basically omit refetching of the files if the browser supports it (most new ones do) if the hash doesn't change. Personally I don't really care that much as we cache them for a day now already. And re validating is done based on Etag. This would just be another optimization in that direction. |
skjnldsv
commented
Jan 18, 2018
I'm in, seems like the proper way to do it. But yes, we override the cache by switching the hash in updates so we should be clear here :) |
rullzer
commented
Jan 18, 2018
Ok then let me pick this up later today so we can get it in :) |
rullzer
commented
Jan 18, 2018
So second question. do we want different behaviour in debug mode? Currently we did not and it was still cached for a day. Which seems long. We could also switch to this by default. Less code paths is less things that can do 💥. |
MorrisJobke
commented
Jan 18, 2018
@skjnldsv Could you give me an overview of how changes are detected? because I doubt that we are looking for the mtime for all involved files on every request, right? |
rullzer
commented
Jan 18, 2018
@MorrisJobke the hash is generated from the appversion it is part of. We could check the mtime (the SCSSCacher has all this info). But of course that would kind of kill performance. Maybe it is best to have guidelines
Note that this PR just changes the duration. Not the way things work. Right now people can also have outdated files on their dev instances for a day if they don't force refresh ;) |
rullzer
commented
Jan 18, 2018
Ah better idea. We could just generate a random hash when debug mode is set? Sure it sucks speed wise. But will work all the time. |
rullzer
commented
Jan 26, 2018
Ok let me convert this jsut to always use immutable. And then we tackle the other problems some other way. My reasoning:
|
Codecov Report
@@ Coverage Diff @@## master #7904 +/- ##
=========================================
Coverage ? 51.86% Complexity ? 25377 =========================================
Files ? 1608 Lines ? 95178 Branches ? 1377 =========================================
Hits ? 49366 Misses ? 45812 Partials ? 0
|
rullzer
commented
Mar 8, 2018
We have #7244 So just tell the browser to do aggressive caching. In debug mode you don't request those files anyway and just fetch the plain files. Ready for review! |
| } | ||
| $response->cacheFor(86400); | ||
| $ttl = 365000000; |
There was a problem hiding this comment.
Not really ... just roughly 41667 years 😜
There was a problem hiding this comment.
Maybe set it to a year: 8760 and until then the instance is updated anyways. ;)
There was a problem hiding this comment.
I was wrong - as this is seconds it is only a bit over 11,5 years
There was a problem hiding this comment.
It was is used in all the example of the immutable object
There was a problem hiding this comment.
Sure. I mean it doesn't really make a difference. But as you wish 😉
| } | ||
| $response->cacheFor(86400); | ||
| $ttl = 365000000; |
MorrisJobke
left a comment
There was a problem hiding this comment.
Tested and works 👍 I tested with and without debug mode and both have the same behavior. Beside that the cache now needs to be cleared (or the apps version should be updated) if you want to test new (S)CSS/JS for example.
rullzer
commented
Mar 8, 2018
@MorrisJobke well before we also said (without debug mode) cache this for 24 hours. But I guess if you are actively developping you should hard refresh anyways. As I have seen browsers already honour our 24h caching. |
MorrisJobke
commented
Mar 8, 2018
Sure :) Was just a clarification comment. |
Cache generated CSS forever! Also cache combined JS forever Fix tests Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Fixes#7224
If not in debug mode we basically cache the CSS for ever ;) Else we fall back to the default (1 day) in debug mode.
Most modern browsers support this. And on upgrade we have a cache buster. basically it is just telling supported browsers this will not change.
Todo: