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

Improve caching and invalidation of theme and version.txt #10310

Open
1 of 4 tasks
offtherailz opened this issue May 13, 2024 · 0 comments
Open
1 of 4 tasks

Improve caching and invalidation of theme and version.txt #10310

offtherailz opened this issue May 13, 2024 · 0 comments
Assignees
Milestone

Comments

@offtherailz
Copy link
Member

offtherailz commented May 13, 2024

Description

Some reportings from @tdipisa suggested that something with resources caching may not work as expected.
Expecially was notified that, in some projects, the new update of the TOC was causing issues and needed a cache clean to fix the issue.

Even if not clear how to replicate, @offtherailz did an investigation and identified a possible fail point in the caching system that is consistent with the reporting.
In particular noted that version.txt is sometimes cached by the browser, and this can cause issues with CSS files. No particular findings on JS files instead.

What happens

  • Most of the files (js and resources) have cache invalidation policy done by an hash at build time, attached to every file. This
  • One exception is on the main entry point (e.g. mapstore.js that is anyway invalidated by postponing the hash as query parameter. (.e.g .../mapstore.js?abcd1234). This guarantees to follow the same invalidation policy.
  • The browser anyway caches the text files, even without any indication for caching (e.g. version.txt) - we need to invalidate cache also for this file, and maybe investigate about the policies that made this caching happen.
  • Anyway an exception can be a probable cause of issue is the URL used to download the main theme CSS file. In this case the caching invalidation policy is applyed by postponing with version name to the CSS URL.
    E.g. ...mapstore/dist/themes/default.css?v1.6.5. Maybe the issue with the version.txt cache in the point above can propagate to this file's cache and cause the issue reported.

Proposal:

  • In this case I'd suggest to use hashes also for version.txt (at least)
  • Review if other static files have the same issue (e.g. images, static files of other kinds)
  • Uniform the caching policy of the main theme css with the policy used by js files (with hashes)
    Note: this file have to be properly identify to allow static theme configuration, so we should call a url like themename.css?hash like for the main JS theme. Using themename-<hash>.css may make impossible to configure it statically (e.g. with datadir multiple client setups).

This should improve also the initial loading time (we don't have to wait to load version.txt to load the theme), decoupling more the general caching strategies from the version text.

  • Not browser related
Browser info (use this site: https://www.whatsmybrowser.org/ for non expert users)
Browser Affected Version
Internet Explorer
Edge
Chrome
Firefox
Safari

Other useful information

image

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

No branches or pull requests

4 participants