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

Implement HTTP caching to the webserver #2813

Closed
AuroraLS3 opened this issue Jan 1, 2023 · 1 comment
Closed

Implement HTTP caching to the webserver #2813

AuroraLS3 opened this issue Jan 1, 2023 · 1 comment
Labels
Improvement (UX) Issues that suggest enhancing user experience using the plugin

Comments

@AuroraLS3
Copy link
Collaborator

AuroraLS3 commented Jan 1, 2023

I would like to be able to..

Speed up page loading times on subsequent visits.

Is your feature request related to a problem? Please describe.

Opening the Plan website from a far away (latency) webserver takes longer to get the required javascript and json files. Some of these could already be cached by the browser.

https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching

This can take seconds off the loading time when webserver is on another continent to the user.

Following can be considered cacheable:

  • React bundle files (The resource files do have a last modified date attached to them, either via assetVersions.yml or from files on disk)
  • json_cache contents (They have timestamps tied to them)

Notes from the linked article

  • Use Cache-Control: private header when content is based on cookies
  • Cache-Control: max-age=seconds can be used to define how long response is valid - longer values could be used for bundles
  • ETag: <tag> and If-None-Match: <tag> can be used with 304 Not Modified to use the cached version of files. "servers are free to set the value based on whatever means they choose."
    • Cases where request has no cache stuff in it should also be dealt with (Fresh loads, reloads etc)
  • "considering the overall HTTP ecosystem, it is preferable to provide both ETag and Last-Modified."
  • If something is not to be cached use Cache-Control: no-cache, private

Based on this following could be implemented:

  • For index.html, Cache-Control: no-cache; Last-Modified: ...; Etag: ... https://developer.mozilla.org/en-US/docs/Web/HTTP/Caching#main_resources
  • For react bundle files, Cache-Control: max-age: 2592000; Last-Modified: ...; Etag: <timestamp> - Caching for a month, causes no issues since bundle files have hash in filenames
  • For json, Cache-Control: no-cache, private; Last-Modified: ...; Etag: <timestamp> - This should allow returning a 304 until queries finish. Needs to be checked.
@AuroraLS3 AuroraLS3 added the Improvement (UX) Issues that suggest enhancing user experience using the plugin label Jan 1, 2023
@AuroraLS3 AuroraLS3 changed the title Implement HTTP cache layer to the webserver Implement HTTP caching to the webserver Jan 1, 2023
@AuroraLS3
Copy link
Collaborator Author

The json request caching requires moving the request time timestamp out of the URL since URL is used as the cache key on the browser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Improvement (UX) Issues that suggest enhancing user experience using the plugin
Projects
Status: Done
Development

No branches or pull requests

1 participant