Custom Cache-control headers
-
The header currently sent by Surfer for all requests is
Cache-Control: public, max-age=0This setting causes the browsers to re-request everything that could have been cached instead. If the
max-agevalue could be customizable from settings or somehow else, that would be a lot less strain on the Surfer on Cloudron.My use-case:
I run Surfer behind Cloudflare, and Cloudflare honors the cache settings, but only ifmax-ageis set to a non-zero value. Basically Cloudflare is not caching anything and my Surfer instance is constantly running out of memory because of the number of requests. -
Even a setting of a few seconds is useful
-
So surfer already sets the ETag https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag but no
max-ageThe max-age setting basically makes the browser not even check in the with server if the content may have changed.Now various frameworks set the
max-agevery high and use other cash busting techinques (like changing the file path hash) to serve up-to-date content if needed.For surfer this is hard to implement, as the main html pages have to be aware of this. So I am not sure how surfer can set
max-ageand ensure that content is fresh at the same time. -
In theory ,
max-age=0means the same asno-cache.no-cachemeans cache it but always revalidate. It seemsmax-age=0allows stale reuse and thus there is also amust-revalidateto prevent that.Cloudflare has it's own interpretation. Per https://developers.cloudflare.com/cache/about/default-cache-behavior , it won't cache at all with
max-age=0. We have to create a custom page rule - https://developers.cloudflare.com/cache/how-to/create-page-rules/ to override the default caching behavior.So... my interpreation is that we need
Cache-Control: public, max-age=1, must-revalidateif we want this to work out of the box in Cloudflare. -
https://learn.microsoft.com/en-us/azure/cdn/cdn-how-caching-works is an excellent read on some other interpretations.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login