Setting browser side caching makes my images disappear.

Setting browser side caching makes my images disappear.

by Frank B -
Number of replies: 2

Ok all my wordpress and joomla site I can always put this into my Nginx website config and it enables browser-side caching.

# Media: images, icons, video, audio, HTC
location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc|js|css)$ {
  expires 1M;
  access_log off;
  add_header Cache-Control "public";
}


This same code in Moodle makes all my images disappear. Does anyone have the right way to enable browser caching in moodle with nginx?

Average of ratings: -
In reply to Frank B

Re: Setting browser side caching makes my images disappear.

by Gareth J Barnard -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers

Moodle already has browser side caching - hence 'Developer_tools#Purge_all_caches' - so what evidence do you have that its not?

In reply to Gareth J Barnard

Re: Setting browser side caching makes my images disappear.

by Frank B -

Well, the fact that it's not tweakable. That you can't set an expiration date on the cache. That you can't select what you want to cache. (images, video, CSS, js, etc)

I think the 'Developer_tools#Purge_all_caches' refers to the internal file caches that moodle builds up for speed.

Browser-side caching is different. You are telling the browser what elements it should cache and for how long it should cache it for.

These two caches are fundamentally different, though I appreciate the effort.