Skip navigation
Currently Being Moderated

Forcing a browser to ignore cache and display current version of a page

Mar 1, 2013 9:28 AM

I just uploaded some revised pages to my site. When I went to view them online, the older pages displayed instead of the new ones - since the older ones were in my browser cache (same thing happens in both I.E. and Firefox).  Going into I.E.'s Tools menu and deleting Temporary Internet Files  fixes the problem on my machine, but if Joe Blow viewed my site recently, then checks again today, he's seeing the older versions - correct?  So my question is, is there something I can do to my pages to force browsers to always display the latest version? Or is this something that can only be done locally by a visitor to the site (who, of course, won't have a clue that he's looking at an obsolete page and needs to delete his cache)?

 
Replies
  • Currently Being Moderated
    Mar 1, 2013 9:54 AM   in reply to Mick8888

    In .htaccess file:

    <FilesMatch "\.(htm|html)$">

      ExpiresActive On

      ExpiresDefault A1

      Header append Cache-Control must-revalidate

    </FilesMatch>

    This makes HTML files to expire in 1 second. You can add css, js etc in the first line if you wish.

     

    --

    Kenneth Kawamoto

    http://www.materiaprima.co.uk/

     
    |
    Mark as:
  • Sudarshan Thiagarajan
    4,000 posts
    Oct 15, 2010
    Currently Being Moderated
    Mar 1, 2013 8:39 PM   in reply to Mick8888

    Times that you can't access your website's .htaccess, a simple meta tag within your HTML file should work - but, be aware that this will work only when your user's existing browser has visited this file (with the meta tag in it).

     

    Read this solution on StackOverflow: http://stackoverflow.com/questions/1341089/using-meta-tags-to-turn-off -caching-in-all-browsers

     
    |
    Mark as:
  • Currently Being Moderated
    Mar 2, 2013 3:38 AM   in reply to Sudarshan Thiagarajan

    no-cache meta tag has been around for a long time and may be that's enough for some cases, however it's worth noting:

    1. It's not a "right" approach and therefore this meta tag is not a valid HTML5 (and should fail when you validate)
    2. Therefore browsers may/should ignore it (although it may still work) 
    3. It will not prevent caching other than at the browser level, i.e. you still receive a cached copy from proxy servers
    4. All other dependent files (scripts, styles, images etc) will still be cached

     

    --

    Kenneth Kawamoto

    http://www.materiaprima.co.uk/

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points