The header currently sent by Surfer for all requests is
Cache-Control: public, max-age=0
This 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.
I run Surfer behind Cloudflare, and Cloudflare honors the cache settings, but only if
max-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.
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 as
no-cachemeans cache it but always revalidate. It seems
max-age=0allows stale reuse and thus there is also a
must-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.