Is updating a linked file meant to cache like that....?

Is updating a linked file meant to cache like that....?

by Howard Miller -
Number of replies: 3
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Familiar scenarion...

* Upload a file and link a resource to it.
* Change the file... upload a new one of the same name

The old file is cached and it's anybody's guess when the users see the new version. I've done some poking about and it does look like Moodle is responsible (not 100%). It seems to do this regardless of cache settings. I'm surprised this hasn't been addressed.

Am I just missing something or is this one of those impossible to fix things??
Average of ratings: -
In reply to Howard Miller

Re: Is updating a linked file meant to cache like that....?

by Helen Foster -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Howard,

I found the following config setting mentioned in the discussion overwriting resource files:

// Seconds for files to remain in caches. Decrease this if you are worried
// about students being served outdated versions of uploaded files.
// $CFG->filelifetime = 86400;

If you find it helpful, perhaps you could add the information to Resources FAQ. wink
Average of ratings: Useful (1)
In reply to Helen Foster

Re: Is updating a linked file meant to cache like that....?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Ahh... ok. The upshot is that file.php generates a "cache-control" header. The default is a whole day, so it's perhaps not surprising that this can cause some confusion. Setting it to 0 should turn the thing off. If that's a good idea is another matter entirely.

I'll add something to those docs.

Thanks Helen - again big grin
In reply to Howard Miller

Re: Is updating a linked file meant to cache like that....?

by sam marshall -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers
This is really beneficial for performance if your pages load a lot of things through file.php (images etc), so it might be better not to turn it off entirely. (Actually, Moodle should probably make an effort at sending these headers for more types of file...)

You might want to reduce it but keep it within the range of a typical user session; for example 1 hour (3600).

--sam