Control browser cache via http headers

Hello,

A couple of weeks ago I had opened this topic about brower cache.
I thought I had found the solution but it did not work properly.

Now I have found a solution that does work but I have to edit the Nginx configuration file for it.

location / {
	# Expose this directory as static files.
	root /home/user-data/www/example.com;
	index index.html index.htm;

# kill cache
add_header Last-Modified $date_gmt;
add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
if_modified_since off;
expires off;
etag off;
}

The problem is that this wil probably be overwritten with future updates?

Am I the only one with this issue in the first place?
Is it possible to include a better cache control setting by default?
Of even better is it possible to make these kind of changes editable via the admin page?

If your site requires editing nginx configs, then you are likely using MiaB for something it isn’t intended to do, and may cause other problems.

You may want to consider using a different server for hosting those sites.

The website is a simple html website created with Publii.
The problem is, when I change something the visitors so not always see the changes directly. It can take hours before browsers decide to reload the page.

As I had stated in the previous discussion, this is an issue with the pages being served.

If you hand-write a simple HTML page, then view it in the other browsers, then make some simple change, the change will be immediately visible even to browsers that had previously loaded the page.

If this is not the case, you need to investigate why, because the default MiaB nginx config shouldn’t be causing this behavior. I have several simple HTML sites for every domain that otherwise doesn’t have a home and is serving mail - this is a little trick that for some large email providers demonstrates a proof of work and helps with inbox delivery.

This topic was automatically closed after 61 days. New replies are no longer allowed.