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 routeInfo.json and react-static-routes.js #516

Closed
arlair opened this issue Mar 24, 2018 · 3 comments
Closed

Caching routeInfo.json and react-static-routes.js #516

arlair opened this issue Mar 24, 2018 · 3 comments

Comments

@arlair
Copy link
Contributor

@arlair arlair commented Mar 24, 2018

I noticed in the build routeInfo.json and react-static-routes.js don't have a hash in the file name, so caching them is difficult.

Would hashes on these files be useful to have, or is there some better way to achieve this?

I did find this code in src/client/methods.js

routeInfo.json?${process.env.REACT_STATIC_CACHE_BUST}

but no mention of how to use it. Presumably you set the environment variable REACT_STATIC_CACHE_BUST to a value before you build.

I seem to recall reading before query strings aren't great for caching, eg:

Query strings on the other hand, have been known to cause caching issues. Some proxies or CDNs aren’t even able to cache files that contain query strings and it is recommended not to use them. Additionally, If you run your site through a site speed test, it will likely return a suggestion to remove query strings. Therefore, when using cache busting, try to use file name or file path versioning wherever possible.
https://www.keycdn.com/support/what-is-cache-busting/

@tannerlinsley
Copy link
Contributor

@tannerlinsley tannerlinsley commented Mar 28, 2018

There are edge cases that limit us from using a hash in the filename for these files. If you would like to investigate and PR a fix, then please do!

@ilijaNL
Copy link

@ilijaNL ilijaNL commented Aug 26, 2018

There are edge cases that limit us from using a hash in the filename for these files. If you would like to investigate and PR a fix, then please do!

What are the edges cases? Since I think this can improve caching dramatically...

@kosich
Copy link

@kosich kosich commented Apr 8, 2019

I think I've just run into this caching issue.
I've updated route data structure and I think I was getting an old cached data.
(though, with cache issues you just can't be 100% sure what happened :) )

NOTE: I'm still on 6.3.6 version, so this might be irrelevant for v7.

@tannerlinsley , do you think we could add that anti-cache query string by default?

I mean something like

routeInfo.json?${ process.env.REACT_STATIC_CACHE_BUST || RANDOM_UUID }

Thank you for your time

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants