1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Force users cache to update???

Discussion in 'HTML & Website Design' started by cocoMonkey, Dec 15, 2014.

  1. #1
    Hi guys,

    My site is mainly static content - so most of the time - I want my site in everyone's cache for as long as possible. I have this in my htaccess file:

    BUT - I'd like to force a whole site update - THEN continue caching the site. In pseudo code -

    IF CACHE IS OLDER THEN 15th DEC 2014 THEN RENEW CACHE
    IF CACHE IS NEWER OR SAME AS 15th DEC 2014 THEN LOAD FROM CACHE

    Is this possible? I don't mind if this is done in the header, in php, JS, but I'd rather not change my htaccess file.

    Thanks for the help!
     
    cocoMonkey, Dec 15, 2014 IP
  2. WzForum

    WzForum Well-Known Member

    Messages:
    320
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    110
    #2
    you can use this code to update to the newest version of your site:

    // Check if a new cache is available on page load.
    window.addEventListener('load',function(e){
    window.applicationCache.addEventListener('updateready',function(e){if(window.applicationCache.status == window.applicationCache.UPDATEREADY){// Browser downloaded a new app cache.// Swap it in and reload the page to get the new hotness.
    window.applicationCache.swapCache();if(confirm('A new version of this site is available. Load it?')){
    window.location.reload();}}else{// Manifest didn't changed. Nothing new to server.}},false);
    },false);
    Code (JavaScript):

    For more info check
    www.html5rocks.com/en/tutorials/appcache/beginner/
    Code (markup):
     
    WzForum, Dec 15, 2014 IP
  3. COBOLdinosaur

    COBOLdinosaur Active Member

    Messages:
    515
    Likes Received:
    123
    Best Answers:
    11
    Trophy Points:
    95
    #3
    The only thing I would add is that it is not support by IE9 and earlier.
     
    COBOLdinosaur, Dec 15, 2014 IP
  4. CYCchips

    CYCchips Active Member

    Messages:
    267
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    88
    #4
    what happen if you update or redesign your pages or posts if long expiry cache show old images still
     
    CYCchips, Dec 15, 2014 IP
  5. COBOLdinosaur

    COBOLdinosaur Active Member

    Messages:
    515
    Likes Received:
    123
    Best Answers:
    11
    Trophy Points:
    95
    #5
    If you use appCache the only way to modify what is cached is to update the manifest.
     
    COBOLdinosaur, Dec 15, 2014 IP