Note: You are currently viewing documentation for Moodle 2.2. Up-to-date documentation for the latest stable version is available here: Cache.
Cache is a block of computer memory or local hard drive space for temporary storage of data likely to be used again. The use of cache improves performance. This page will focus upon cache that is typically used on the Moodle server and by most web browsers.
There is a communication process between the web server and a web browser that can impact cache on either of them.
A common question with Moodle (or other web based programs) is "I changed the words or uploaded a new version of a picture, but when I view the web page nothing has changed. What am I doing wrong?" Part of the answer to this question will involve "cache" of part of the Moodle code on the server and/or how cache is handled by the student's web browser. Typically the person will be told to "purge", "empty", "refresh" or "dump" the cache. Basically this means to delete the temporary files and that will force an updated copy of the changed information into cache.
Simple example of how cache works on the web
Here is a simple non-technical example of how cache works. A teacher has created a course on Mountains and put a picture of Mount Blanc on the home page. The site administrator purges all caches. Immediately after that, the first student enters the course. The student's web browser asks the Moodle server for information about that page. The server compiles a page, puts a copy of that information in it's cache and sends another copy along to the student's web browser. There are now essentially 3 copies of the web page out there. The student's web browser stores the copy in it's "temporary internet files" and displays the information. There are now essentially 5 copies of the web page.
The student leave the home page to go to an assignment. The same process is repeated. The student sees the initial assignment page on their screen, their web browser as stored a copy as a temporary file, the Moodle server has stored a temporary file in it's cache and can recompile the page from original data.
The student decided to go back to the course's home page. The student's browser and the Moodle server compare notes and determine that nothing has changed on the courses homepage, the browser goes to it's temporary internet files and displays the cache. This saves the web server from having to send all the page information form it's cache over the internet to the browser. Also since the server used cache, it did not have to recompile the page which saved time and resources.
When the teacher changes the picture of Mount Blanc to Mt. McKinley, then what happens to the caches?
Moodle server caches
Moodle can cache some parts of its program on a longer term basis. When these are edited, cache on the server needs to refreshed. The site administrator can refresh all caches on the server by running
Site administration > Development > Purge all caches.
- Language packs - when language's are customized, part of the process is to refresh the language caches. The site administrator will see several language cache options in Site administration > Language > Language settings.
- Themes - when the theme code is customized it is a good idea to clear "theme caches" by the Site administration > Appearance > Theme > Theme selector menu.
- All caches - Site administration > Development > Purge all caches could slow down your site but it will delete all cached information and then renew them as needed.
Local browser caches
Each browser can have and usually maintains its own set of cache information. Each browser can be set up independently, with its own rules for managing cache. This can be confusing to the user, where different users see different information when on the "same" page.
The user can update their browser cache for a page by clicking on the browser refresh button.