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

major version pinning is not suitable for production - cache is too long with up to 14 days of cache #18532

Open
2 tasks done
samuelstroschein opened this issue Oct 6, 2023 · 5 comments

Comments

@samuelstroschein
Copy link

samuelstroschein commented Oct 6, 2023

Edit

This seems like a bug rather than a feature request. The major version pinning caching times with 7 days, leading to worst case 14 days of cache are too long for a production use case. I updated the issue accordingly.


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

JSDelivr's caching is unsuited for major version pinning, where a module should update as soon as a new minor version is released.

We are recommending JSDelivr for inlang plugins. The fact that a JSDelivr link only updates after approximately 1 week due to JSDelivr's caching itself and the response headers leads to numerous bugfixes that are not immediately deployed. See opral/monorepo#1404 (comment) as an example.

In the worst case, it takes 14 days until a user receives the latest version.

2023-01-01 plugin v1.0 is released (jsdelivr caches for 7 days)
2023-01-02 user requests plugin@1 -> receives 1.0 (browser caches for 7 days)
2023-01-03 plugin v1.1. is released
2023-01-03 user requests plugin@1 -> receives outdated browser cache hit 1.0 
2023-01-04 user requests plugin@1 -> receives outdated browser cache hit 1.0 
2023-01-05 user requests plugin@1 -> receives outdated browser cache hit 1.0 
2023-01-06 user requests plugin@1 -> receives outdated browser cache hit 1.0
2023-01-07 user requests plugin@1 -> receives outdated browser cache hit 1.0 
2023-01-08 user requests plugin@1 -> receives outdated browser cache hit 1.0 
2023-01-09 user requests plugin@1 -> browser refetches jsdelivr which is on day 6 of cache) -> receives 1.0 (!)
2023-01-10 jsdelivr purges cache. resolves 1.1 now
2023-01-11 user requests plugin@1 -> receives outdated browser cache hit 1.0 
2023-01-12 user requests plugin@1 -> receives outdated browser cache hit 1.0 
2023-01-13 user requests plugin@1 -> receives outdated browser cache hit 1.0 
2023-01-14 user requests plugin@1 -> receives outdated browser cache hit 1.0 
2023-01-15 user requests plugin@1 -> receives outdated browser cache hit 1.0 
2023-01-16 user requests plugin@1 -> browser refetches jsdelivr -> receives 1.1

Describe the solution you would like.

Reduce the cache time to a day or 12 hours like branches.

Describe alternatives you have considered.

Moving off of JSDelivr.

Requisites

  • I performed a cursory search of the issue tracker to avoid opening a duplicate issue.
  • I understand that not filling out this template correctly will lead to the issue being closed.
@MartinKolarik
Copy link
Member

Hey, have you tried the purge API? It should work well in this case: https://github.com/jsdelivr/jsdelivr#purge-cache

@samuelstroschein samuelstroschein changed the title no cache option - blocking production use cases - willing to pay for implementation major version pinning is not suitable for production - cache is too long with up to 14 days of cache Oct 6, 2023
@samuelstroschein
Copy link
Author

samuelstroschein commented Oct 6, 2023

hey @MartinKolarik, purging doesn't help since jsdelivr is also setting response max time headers of 7 days. hence, the browser will cache a link for 7 days in addition to jsdelivr caching 7 days. The worst case result is a close to 14 days cache.

I updated the issue. The solution seems obvious. Reduce the caching time for version pinned modules to 12/24 hours.

@MartinKolarik
Copy link
Member

Quick note: the CDN cache time is only 12 hours already, as indicated by s-maxage. The problem in your case is indeed likely the client cache.

@samuelstroschein
Copy link
Author

Good remark. In that case, the problem seems mostly jsdelivr purging-related.

Lowering the JSDelivr cache time to 12 hours for major versions seems beneficial as we can't, and therefore jsdevlivr too, require developers to set up CI/CD to purge (too long) JS deliver caches.

Would lowering the JSDelivr cache time from 7 days to 12 hours for major/minor versions be okay for JSDelivr?

@mfcc64
Copy link

mfcc64 commented Jan 27, 2024

max-age=604800, s-maxage=43200, is this really intended? (7 days client cache, 12 hours CDN cache)
Or should it be max-age=43200, s-maxage=604800? (12 hours client cache, 7 days CDN cache)

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

No branches or pull requests

3 participants