adventureland icon indicating copy to clipboard operation
adventureland copied to clipboard

Add cache headers to static resources

Open earthiverse opened this issue 1 year ago • 7 comments

  • Pretty format the YAML file
  • Add Cache-Control headers to images, css, and sounds (things that are unlikely to change between versions)

earthiverse avatar Jan 25 '24 22:01 earthiverse

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.

thmsndk avatar Jan 26 '24 09:01 thmsndk

A lot of the URLs in this game have ?v=### appended to them. This breaks the cache when you increment the number.

earthiverse avatar Jan 26 '24 09:01 earthiverse

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.

FreezePhoenix avatar Jan 26 '24 12:01 FreezePhoenix

I would also like to mention that although they were not marked with cache before, many browsers are intelligent enough to still cache them.

FreezePhoenix avatar Jan 26 '24 12:01 FreezePhoenix

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.

Telokis avatar Apr 12 '24 18:04 Telokis

So, I took a look at this again, and I discovered a few things

  1. expiration: 1d is the correct way to add expiration according to https://cloud.google.com/appengine/docs/standard/reference/app-yaml#handlers_expiration
  2. 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
  3. 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".
  4. ETags are automatically added. Using thmsn's server, it returns 304s (Not modified) for all the resources.

earthiverse avatar Apr 16 '24 03:04 earthiverse

@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!

Telokis avatar Apr 19 '24 11:04 Telokis