Note: You are currently viewing documentation for Moodle 2.0. Up-to-date documentation for the latest stable version is available here: Cache.

Cache

From MoodleDocs
Revision as of 11:45, 31 October 2011 by chris collman (talk | contribs) (work in progress)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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?