Issue Details (XML | Word | Printable)

Key: MDL-20042
Type: Bug Bug
Status: Open Open
Priority: Major Major
Assignee: Petr Skoda
Reporter: Daniel Neis
Votes: 0
Watchers: 2
Operations

Add/Edit UI Mockup to this issue
If you were logged in you would be able to see more operations.
Moodle

Problem with browser cache and resource download - solve with Etags?

Created: 11/Aug/09 10:00 PM   Updated: 11/Aug/09 10:00 PM
Return to search
Component/s: Files API, Resource
Affects Version/s: 1.9.5
Fix Version/s: None

Participants: Daniel Neis and Petr Skoda
Security Level: None
Affected Branches: MOODLE_19_STABLE


 Description  « Hide
Hello,

while working on Federal University of Santa Catarina (http://moodle.ufsc.br), some users have reported the following situation:

- The teacher uploads file X
- Then, he links it through a resource on course A
- The student downloads file X for the first time
- Some time after, lets say 10 minutes, the teacher uploads another version of the file with the same name
- When the student tries to download the file again, the browser uses a cached version

I have tried to user the $CFG->filelifetime = 1, but the problems still persists. I have read about the HTTP cache mechanisms in http://www.w3.org/Protocols/rfc2616/rfc2616-sec13.html, and i think the follow happens:

* If we put the "Expires" too far in the future, the rest of message is discarded, including the new Last-Modified because the old Last-Modified is still valid
* If we put the "Expires" on the past, the browser will always touch the file in the server, discaregarding the Last-Modified, because the message isn't valid anymore

So, we cannot solve this problem using this basic header, we have to use ETags: "Entity tags are used for comparing two or more entities from the same requested resource". Basically, the server stores a hash of the file+timemodified (or just the file), and sends to client on the header response, if the hash matches one in the browser caches then it is used, otherwise the browser asks for the server to send the new file.

It will cause, of course, a performance overhead, but we can think about some way to cache things.

What do you think?

 All   Comments   Change History   Version Control      Sort Order: Ascending order - Click to sort in descending order
No changes have yet been made on this issue.