Browser caching


(Gavin Boyd) #1

We run matrix, nginx, squid cache. Browser caching has not been disabled.

Question is, Matrix offers Root node cache management tool. But does not seem to work for setting browser cache expiry.

All our images have a browser cache-control of 6 hours. We want to change this to 1 month. We have setup root node cache management, but this has no effect.

Why does root node cache management config in matrix not take effect?

Screenshot: https://photos.app.goo.gl/BePe1AyxeRDtxr0e2

Running Matrix v5.4.0.2


(Marcus Fong) #2

The main possibility I can think of is if you’re trying to change the cache expiry of files (including images) which are live, public and have Unrestricted Access enabled (i.e. their relative URL path starts with /__data/).

In that case they’re served directly as files from nginx, bypassing all PHP code execution including the Matrix Cache Manager. This improves performance, but also means that you’d need to set the Cache-Control header in your nginx configuration, by adding or changing the expires directive under the __data location:

location /__data {
        expires 1M;

The other alternative would be to disable Unrestricted Access on your files, forcing them to be served through Matrix and allowing your cache settings to take effect. Performance would be lower but Squid would normally compensate for most of that. (Also note that if you do this, it would be best to arrange a flush of your entire Squid cache to avoid any broken links or image references, since it would change the URLs of all your files.)