This question about Issue in browser: Answered

How to force a page to skip cache?

Issue: I have a topic with a .doc attachment that is sometimes updated. However, when visitors come to the topic and click the attachment link, they get the old version from the cache and not the new version from the server.

Question: Can I force a page (including its attachments, or specifically just the attachment) to be loaded from the server at all times?
The normal tactics for expiring the browser cache are:
  1. Deliver the data with a cache header
  2. Change the link in some way so that it isn't matched the same way again
When you click on an attachment link in a topic view, you are simply making a reference to a file in the Foswiki 'pub' area on the apache server. Apache takes over from there, and delivers the file to the client. I imagine that apache will support some way to force a cache header onto files referenced from the pub header, but I haven't researched the subject. I suspect it will probably involve mod_expires, though.

Changing the link in this case involves a trivial edit to one of the template files, templates/attachtables.tmpl. Find the following fragment in that file: <a href="%ATTACHURLPATH%/%ENCODE{%A_FILE%}%"> and change it to this: <a href="%ATTACHURLPATH%/%ENCODE{%A_FILE%}%?t=%GMTIME%">. the addition of the t=GMTIME parameter will ensure that a different link is used each time the file is downloaded, as long as the page being viewed has been refreshed since the attachment last changed.

This second technique works, but only affects the link in the attachment table at the foot of the topic. Links to attachments in the body text will still work the old way. So if you can find a solution using Apache, that would be best.

-- CrawfordCurrie - 09 Apr 2009

QuestionForm edit

Subject Issue in browser
Version TWikiRelease04x03x00
Status Answered
Topic revision: r2 - 09 Apr 2009, CrawfordCurrie - This page was cached on 09 Jan 2018 - 19:21.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License