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

Caching settings #1146

Merged
merged 2 commits into from
Jun 2, 2020
Merged

Caching settings #1146

merged 2 commits into from
Jun 2, 2020

Conversation

jameshadfield
Copy link
Member

This PR builds on #1126 and enforces that index.html is never cached, as it gets recreated when auspice rebuilds and the src for the main JS bundle changes accordingly. This may not be strictly necessary, as the max-age was 0 and the ETag changes as the file changes, but setting this explicitly is good practice.

JS bundles, which use hashes to facilitate cache busting, are served with a 30d cache lifetime. Note that this is not enough to force browsers to not revalidate within the 30d (i.e. 304 response) -- see this post for context. Re-validation during the 30d lifetime will return a 304 which is no worse than the current situation we have.

@salvatore-fxpig would you mind double checking this?

@jameshadfield jameshadfield temporarily deployed to auspice-caching-setting-ssmizi May 29, 2020 03:00 Inactive
All static assets are asked for under the `/dist` prefix and handled by the `expressStaticGzip` handler.
This commit (building on top of #1126) enforces that
index.html is never cached, as it gets recreated when auspice rebuilds and the src for the main JS bundle changes accordingly. This may not be strictly necessary, as the max-age was 0 and the ETag changes as the file changes, but setting this explicitly is good practice.

JS bundles, which use hashes to facilitate cache busting, are served with a 30d cache lifetime. Note that this is not enough to _force_ browsers to not revalidate within the 30d (i.e. 304 response) -- see [this post](https://stackoverflow.com/questions/26166433/how-to-prevent-request-that-returns-304/26339940#26339940) for context. Revalidation during the 30d lifetime will return a 304 which is no worse than the current situation we have.
@jameshadfield jameshadfield temporarily deployed to auspice-caching-setting-uu7myc May 29, 2020 03:34 Inactive
jameshadfield added a commit to nextstrain/nextstrain.org that referenced this pull request May 29, 2020
See nextstrain/auspice#1146 for rationale for these
changes. Depending on how gatsby is creating assets, we could improve
the cache-control for those in a future PR.
jameshadfield added a commit to nextstrain/nextstrain.org that referenced this pull request May 29, 2020
See nextstrain/auspice#1146 for rationale for these
changes. Depending on how gatsby is creating assets, we could improve
the cache-control for those in a future PR.
@salvatore-fxpig
Copy link
Contributor

salvatore-fxpig commented May 29, 2020

I tested this both with Chrome with cache on and off, and with cUrl to simulate revalidation.

Chrome cache works as expected, and 304s are returned correctly as well both for If-None-Match and If-Modified-Since headers (as before).

So all looks good as far as I can tell @jameshadfield .

@jameshadfield jameshadfield merged commit 290e482 into master Jun 2, 2020
@jameshadfield jameshadfield deleted the caching-settings branch June 2, 2020 06:42
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

Successfully merging this pull request may close these issues.

2 participants