Custom Cache-control headers
-
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-age
value 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-age
is 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-age
The 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-age
very 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-age
and ensure that content is fresh at the same time. -
In theory ,
max-age=0
means the same asno-cache
.no-cache
means cache it but always revalidate. It seemsmax-age=0
allows stale reuse and thus there is also amust-revalidate
to 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-revalidate
if we want this to work out of the box in Cloudflare.