adventureland
adventureland copied to clipboard
Add cache headers to static resources
- Pretty format the YAML file
- Add Cache-Control headers to images, css, and sounds (things that are unlikely to change between versions)
How do we force the cache to reset then, if they in fact change between versions? We can't instruct all players to open dev tools and disable cache :P
Some sort of cache busting mechanism is important.
A lot of the URLs in this game have ?v=###
appended to them. This breaks the cache when you increment the number.
Earthiverse is right - all that has to be done is change the URL parameters used to access it, and voila - your browser is convinced it is a new file.
I would also like to mention that although they were not marked with cache before, many browsers are intelligent enough to still cache them.
Hey, thanks for this PR!
Where there is caching, I would like to see etag
as well. Does this automaticall handle it or does it require additional configuration?
Once etag
is enabled, we can increase the caching duration even more.
So, I took a look at this again, and I discovered a few things
-
expiration: 1d
is the correct way to add expiration according to https://cloud.google.com/appengine/docs/standard/reference/app-yaml#handlers_expiration - The default cache timeout is 10 minutes according to https://cloud.google.com/appengine/docs/standard/how-requests-are-handled?tab=python#static_cache_expiration
- It doesn't look like it's being applied. It might be because we're using a dev version of the app engine. I'm not sure how to mimic "production".
- ETags are automatically added. Using thmsn's server, it returns 304s (Not modified) for all the resources.
@earthiverse Ok, thanks for clarifying. I can't access any of the links you've provided, they all return "Service unavailable", weird.
In any case, I think we can proceed with the setup you've specified and then we'll see how it behaves and make changes accordingly.
I see you've marked it as draft, I assume you want to test or figure some things out before merging so feel free to tag me when I can review it again and you consider it ready!