Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 4 of 4
  1. #1
    Member
    Join Date
    Aug 2008
    Location
    Utah, USA
    Posts
    38
    Member #
    17184
    Hi, I'm new to the forum. I have a question. I couldn't find it anywhere when I searched. Is there a code (html or maybe js) that I can embed into a website to trigger the viewers cache to refresh? The website that I need this for is updated very regularly and my director is concerned about returning viewers loading old images, etc. when they come back to the site. Thanks.

  2.  

  3. #2
    Senior Member
    Join Date
    May 2003
    Location
    UK
    Posts
    2,354
    Member #
    1326
    Not sure if theres a code to refresh the users cache (there is to refresh the page obviously). However you can ensure that your pages are not cached at all meaning when they are requested they will fetch the file and not load from cache.

    http://www.htmlgoodies.com/beyond/re...le.php/3472881

  4. #3
    Senior Member Brak's Avatar
    Join Date
    Apr 2003
    Location
    San Francisco, CA
    Posts
    3,413
    Member #
    1217
    Liked
    2 times
    The only foolproof method to doing this is to change the filename, either directly or through querystrings. So let's say you have an image on the homepage you don't want to be cached:

    Code:
    <img src="header.jpg" />
    One method is to use a server-side language to append a random number as a query string like so:

    Code:
    <img src="header.jpg?13028350923802380927" />
    Or more simply, change the name of the image in the HTML each time the image is changed:

    Code:
    <img src="20080811_header.jpg" />
    You'll need to do this for CSS, Javascript and any images you'd like to refresh. But also keep in mind that this forces people to re-download assets that they might want to cache. The best alternative is to only change these querystring values each time you deploy a new version of your website.

    Doing that requires a lot more complex programming though, unless you're using something like Merb/Rails, where asset-caching on deploy is done automatically through the asset helpers.
    Kyle Neath: Rockstar extraordinare
    The blog | The poetry site | The Spore site

  5. #4
    Member
    Join Date
    Aug 2008
    Location
    Utah, USA
    Posts
    38
    Member #
    17184
    I think these worked. Thanks for the help.


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 11:14 PM.
Powered by vBulletin® Version 4.2.3
Copyright © 2022 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com