Forced refresh on pages with user pics?

Forced refresh on pages with user pics?

by Fernando Oliveira -
Number of replies: 3
Picture of Plugin developers

When someone changes her profile picture, can other users see the change if they never manually refresh their screen? ...or does the cached pic remain indefinitely?  

I'm wondering what the positives/negatives might be if a page refresh command was hard coded into the pages that display profile pics. Would it be difficult\worthwhile to insert a few lines that refresh the page after a profile pic has been changed (assuming such changes can be tracked without too much coding)?

I'd be grateful if someone could comment on this before I approach our programmer (I'm not a coder... please put down the stones! big grin)

Thanks in advance,

Fernando

Average of ratings: -
In reply to Fernando Oliveira

Re: Forced refresh on pages with user pics?

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Its not quite that simple, as a local proxy maybe caching the image, so refreshing the page - however done - may not make any difference.

The way I have got around this in the past (in other web applications) is to simply add a random value into the image link, so if the link is something like...

file.php?id=99 (or whatever)

add a bogus parameter

file.php?id=99&stuff=2673633

...where the number is random. Not very hard to code. As the URL changes every time this forces the image to be re-read every time (stuff will just be ignored). This reduces overall performance though. There is always a tradeoff!
In reply to Fernando Oliveira

Re: Forced refresh on pages with user pics?

by Martin Dougiamas -
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers
Caching on images is currently set to a day or something (see cvs:/moodle/user/pix.php) ... so even if nothing is done it will come through soon enough ..

It possible that in the function that prints user image references, that it could check the filedate every time, and if it's less than a day old then it uses Howards random number trick.  Of course checking the file date for EVERY user image every time is a performance hit.
In reply to Fernando Oliveira

Re: Forced refresh on pages with user pics?

by Fernando Oliveira -
Picture of Plugin developers

The image caching is indeed set to one day ($lifetime = 86400;). That sounds like a reasonable time, but does this hold true regardless of a local proxy?