-
I was asked why I set the server cache twice the browser cache: github-readme-stats/api/index.js Lines 68 to 73 in 2ee803f I will use this discussion post to explain my reasoning. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I use CACHE/2 in the browser for the following specific scenario:
However, if both the browser cache and server cache are set to 4 hours, this second user won't receive a new card upon returning after the server cache expiration. This is because their browser cache is still active for another 2 hours. This caching strategy ensures that users receive up-to-date content when their browser cache expires while leveraging longer CDN cache periods for better performance and reduced server load. @anuraghazra, @qwerty541 since this is quite an edge case, we can also simplify the code and set both the server and browser cache to the same period 👍🏻. |
Beta Was this translation helpful? Give feedback.
I use CACHE/2 in the browser for the following specific scenario:
Imagine one user requests a card at 12:00. In this scenario, the user's browser cache is configured to retain content for 2 hours, while the CDN cache is set to 4 hours.
Now, consider another user who visits the same card 2 hours before the server cache (CDN cache) expires. This action extends their browser cache period to 4 hours.
If this second user returns after 2 hours when the server cache has already expired, they will receive a fresh card from the server.
However, if both the browser cache and server cache are set to 4 hours, this second user won't receive a new card upon returning after the server cache expi…