Extending browser cache

Extending browser cache

by Benjamin Bøndergaard -
Number of replies: 3

Hello moodle
I am trying to figure out how to reduce server load by extending browser caching.
Right now many of the image files only have a cache lifetime of 1 hour, which is almost nothing compared to the standard of 1 year.
This 1 hour is hard-coded into the core because the images come from pluginfile.php/xxxxx/course/overviewfiles/
Is there any way to change this without editing core core?
I have used htaccess to change headers, but found that moodle overrides these headers.

Running moodle 3.7.1

Average of ratings: -
In reply to Benjamin Bøndergaard

Re: Extending browser cache

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Welcome to Moodle... it would be really good if you changed your profile to show your *real* name. We like to know who we're speaking to wink
In reply to Benjamin Bøndergaard

Re: Extending browser cache

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
If you set the files to cache for 1 year, and then want to change the image, you can't reliably.

Moodle lets users change the image through the UI.

Hence, 1 hour seems like a good compromise.

If you want more sophisticated caching, put a CDN in front of your Moodle site.
Average of ratings: Useful (2)
In reply to Tim Hunt

Ang: Re: Extending browser cache

by Benjamin Bøndergaard -
I see. I initially thought the url changed when you uploaded a new image (with the same filename), since I saw a plugin do that for one of their images.
But upon further investigation I can see that this is not true for course images.

Wouldn't it be better if the url changed (timestamp) every time a new image (with the same name) was uploaded to moodle, just like js and css gets a timestamp in their url?

But as of now I will go with your suggestion of extending cache on a CDN level. smiler