cytoscape / cytoscape-explore

Network visualization webapp.
MIT License
13 stars 4 forks source link

Cache busting old .js and .css files #98

Open d2fong opened 2 years ago

d2fong commented 2 years ago

Describe the bug Because src/views/index.html links to statically named main.js, 'deps.js,main.css,deps.css` files. When it is time to deploy the new bundles, the current system replaces the contents of these files. It may be possible that user runs into an issue with their browser using the cached previous version of the file instead of the new version.

Expected behavior When changes are deployed, we should try to avoid these potential caching issues.

Additional context There were a few ideas discussed such as setting cache control in the server, or appending a build id to the js/css files. How is this issue handled in other projects?

maxkfranz commented 2 years ago

It may be pragmatic to do both eventually. Setting the headers is important, otherwise the user can get a stale index file in the first place. The headers ought to be sufficient, and express sets those by default for static assets like js and css (usually in the public dir): http://expressjs.com/en/resources/middleware/serve-static.html http://expressjs.com/en/resources/middleware/serve-static.html

The headers could fail sometimes, e.g.the reverse proxy isn’t working properly or Chrome decides to be too aggressive in how it caches. So it may make sense to do both. I think the build IDs for tools like webpack are ostensibly for when you don’t have control over the infrastructure, but whatever works

On Nov 16, 2021, at 10:49, Dylan Fong @.***> wrote:

Describe the bug Because src/views/index.html links to statically named main.js, 'deps.js, main.css, deps.css` files. When it is time to deploy the new bundles, the current system replaces the contents of these files. It may be possible that user runs into an issue with their browser using the cached previous version of the file instead of the new version.

Expected behavior When changes are deployed, we should try to avoid these potential caching issues.

Additional context There were a few ideas discussed such as setting cache control in the server, or appending a build id to the js/css files. How is this issue handled in other projects?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/cytoscape/cytoscape-explore/issues/98, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHRO42A5YSC2UL2BT64BYDUMJ4PTANCNFSM5IETLOOA.

maxkfranz commented 2 years ago

Alternatives for index.html handling re. build IDs:

(1) Template for index.html and rebuild the template on each wp build -- watch, build index.template.html.hbs => index.html

(2) Same but dynamic (server side template)