I'm having a little issue with a resource. I uploaded a zip, unzipped it and then linked to the index file as a resource. All was good... until... I found an error in my html files. I deleted the directory, the zip file and the resource link in Moodle, fixed my mistakes and uploaded everything again.
When I try to link to the index page I keep getting the original page with mistakes. If I rename the index page I can see the corrected one (Problem there is that it won't link to the other pages in the directory after the name change).
I tried not deleting files and uploading over top of them hoping for an option to "overwrite" existing files with the same name (no such option). For some reason, half of the files in the directory now are the old ones and half are new.
Any way to fix this without having to snare a programmer?
The problem you describe is due to your browser caching the original html files. (No programmer snare required! ) You don't actually need to delete original files, since if you upload replacement files with the same names, then they overwrite the original files.
In order to view any replacement files, please try a forced refresh (Ctrl+F5). If this doesn't work then please try clearing your browser cache.
I've had some strange experiences with my resources. I had tried deleting files, overwriting files and renaming files all with different results.
This morning I renamed my directory with the new files and it was fine, just for fun I uploaded the same new files in a directory with the original name and the old ones showed up. I went to try the forced refresh when I read your post but the files have miraculously changed themselves so I didn't need to. I had a simillar thing happen yesterday. It's almost as though it just needs a little time to make the changes.
Anyway things seem to have sorted themselves out.
Sometimes even Ctrl-F5 won't do the trick. However, you can fool the caches into thinking they are getting something different by adding a parameter to the end of the URL. So long as its labelled as something the server is not looking for, the server (Moodle in this case) won't notice the difference, but the caches will think they MUST go back to the server to get a new instance.
If there are already some parameters, add the new one after a & (there usually are). If not, you need to add a ? instead.
e.g, this page is
To force a refresh you could send, say
http://moodle.org/mod/forum/discuss.php?d=33376&sadfsdgsddg=dasfdzfzd or any other rubbish.
VERY slightly risky, but it does solve a problem.
Is there an easy way to refresh a frame, I wonder? Or (better still, in my mind), is there a way to get Moodle to load the resource without a surrounding frame?
Please note that resources do not necessarily have to be included in a separate frame. Please check the window settings on the editing resource page.
In the past I tried right-clicking and refreshing in the frame to no avail. But something did work--it's hard to say what, since I was experimenting quickly for a deadline, but it seemed to be the cache erasing. Maybe, as said above, the system just "caught up". Though that didn't work with another resource that had been supposedly overwritten for days, yet still showed the old version. Hmn.
Also, in the "editing resource" page, I don't see an option for no frames. I only see some pop-up options. I may have an unusual version on site, though.
Thanks again for your patience with my questions!
I've also come across occasional refresh problems. One possible solution is to check with a friend who's not yet viewed your resource.
Re. a no frames option, please ensure the box "Put resource in a frame to keep site navigation visible" is left unchecked.
Does anyone know how long the cache will sit whereever it is before the refresh takes effect? I'm getting reports that if we leave it overnight it seems to magically fix itself! It doesn't seem to matter if it is a ctrl + F5, whether it is Firefox or IE whether it is in a frame or just clicked on the resource in the Files section. You can even close all incarnations of the browser down and reopen and we still get the wrong page. This isn't ideal for some of my new to IT tutors who are getting flumoxed by it all.
In your file.php file under the root Moodle directory, edit the file line where it specifies the time the file is to remain in cache. It's line 13.
The default is set to 24 hours (expressed in seconds).
I set mine to 0, closed the browser, changed the file and checked. Every time I changed the file, the change was reflected.
I hope it works for the rest of you.
Regarding the previous solution, use caution!
Otherwise another possible solution that I've found is to place your file in a location other than the folder within the Moodle data directory.
I keep files updated in a folder created via FTP in a location outside of the Moodle install folder. I then point to these files using the full URL location. This bypasses the file.php usage and seems to provide a solution. However, this may not be as secure or convenient since not all users/developers have full FTP access.
The fact that you get the latest version if you try a different machine suggests that it's the cache on the machine that's holding the old version - if it was a cache held on your organisation's proxy server I'd have thought that all machines in your organisation would continue to pick up the old version for a time.
Have you tried changing the cache settings in your browser? (Tools >> Internet Options >> Settings button.) You can change how often the browser checks for new versions of stored pages. Alternatively try clearing the cache (Tools >> Internet Options >> Delete Files button.)
Hope this helps
we don't have a proxy server, and I already have the cache settings in IE set to refresh every visit to the page. Perhaps IE has actually broken that setting and it won't actually matter what I do to it. Perhaps I need to check out the Microsoft site to see if it is them with an issue rather than us!
I will try dumping the entire cache next time I get this problem and see if that does the trick
Does anyone have an answer for this? I have tried all sorts of tricks, including .htaccess commands, resetting the browser cache setting and it is still an issue. Even here it appears, if you update your profile image it does not appear till you refresh the page. I tried resetting the file.php cache setting as well, but that did not work either. Also tried adding a metatag into the header of pages fo no-cache. It is a problem in IE and Firefox. It is OK for me, but I am now starting to get teachers and students telling me there is an error in moodle.
Caching is optional, these are stores where a copy is kept, mainly the idea is to save bandwidth. So they can be on the client machine (browser cache), and/or in your organisation's proxy servers, or upstream caches. For students from home, they will be making requests via an ISP who also has the motivation not to pay for bandwidth if they dont have to. The student is effectively part of the ISPs LAN, so the ISPs proxy may well serve the file from its record of the url in its own caches.
The webserver itself may cache, and finally the application may maintain its own cache system. All in the name of efficiency and cost saving. So the request you make may never make it all the way to the server, there are any number of stores on the way up that might decide to serve you the file instead.
So modifying Moodle? What are you trying to achieve? Your request first has to get to the server through this caching minefield!
Now any sensible application on a server also has a motivation not to be bothered in the future. Web server applications have a motivation to conserve bandwidth, basically they don't want requests for the same again thing in the future, for the same client. So they try to discourage requests ever being made again for the same thing. They do this by issuing "response headers" along with their responses, that are intended to be listened to by any caching systems that the response might encounter on its journey to the user. All care no responsibility.
There is no guarantee that a cache will listen to any headers properly, but on the whole they behave reasonably well. The headers are generally passed on, and you can 'listen" to cache headers as they arrive finally at your client machine. An easy (and educational) way to do that is to install the Firefox or the IE developers toolbars on your browser, and you can see all sorts of things about the web page very easily. (Incidentally, there is no point in sending an HTML metatag to try to influence intermediate caching servers like proxy servers, because they dont look into the HTML content! Tags are rendered in the browser, so you might manage to cause that to do something.)
Any cache keeps (is given) information about a cached file called its "freshness". As long as a cache considers that a file is "fresh", it will stubbornly intercept any request from a client and serve the file itself, and make sure that the request is never passed on to the "origin server". Now can you see a problem? Sure, if the server copy of the file is changed, how can a cache be notified of that fact? The web doesn't work in that direction. Everything has to be requested, you cannot "push" from a web server without a request in the first place. Catch 22.
So the browser people invented a signal (forced refresh) to try to provoke a cache server to refresh from the client end. Or dirty tricks can be used, like OK if that url out of date I will change the url of the resource by adding something onto the end of it, and bypass the whole issue. It was those headers the server issued in the first place that were the problem.
So we have to be really careful what headers we issue in the first place, when telling caches how they will behave toward a file we are serving it for the first time.
The worst offender is a header called the "Expires" header. This sets the freshness to remain until the expires date is reached. Its a very dangerous header to issue if there is any chance that a file will in fact change its contents at some time in the future inside that date. I think this may be the problem that is being faced here?
Moodle has a config setting
// 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;
I am not sure if you can control this setting file by file, because I don't know Moodle that well. There are also other ways of controlling caches, so maybe Moodle will change its approach in the future?
Thanks Keith for your comprehensive reply!
Quote: What are you trying to achieve?
I would like for people to stop calling me telling me there is an error and their resources/personal images etc are not updating on moodle. I keep telling them about the benefits of being able to imediately update a resouce for students, so you can see why they get frustrated. I have had a go at the filetime for the moment, and that seems to work for now.
"Fortunately Moodle has a way around this, by setting the $CFG->filelifetime variable in config.php to 1 second. This causes the file’s “life time” to become exceedingly short, thus forcing your web browser to go and get a new copy instead of the original."
Sounds like a good solution to me!