#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Location
    Florianópolis, Santa Catarina
    Posts
    2
    Rep Power
    0

    Update webdesign of site with upgrade on jquery


    Hello, I migrated my website from an international domain ( sitepor500.com ) to a national domain ( sitepor500.com.BR ) and before I imported the jquery localhost using "jquery/jquery.min.js". Everytime I updated my jQuery I downloaded the most recent version from jquery and then renamed it to jquery.min.js

    The problem is that I updated a very old version 1.6 to 1.9. in the national domain but some users are experiencing problems with my website since I use in my new domain the ".on()" method and users with 1.6 cached in their browser do not recognize the on() cause it used to be .live().

    So my question is, how can I tell to that users browser that they should download again the file jquery.min.js and erase their cache? My apache in the old domain used to tell browser to cache de jquery.min.js to 12 months. The problem is that I changed the version inside my file and those browsers are not downloading the new version!

    Thank you all
  2. #2
  3. A Not To Shabby Code Smurf
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Aug 2008
    Posts
    1,188
    Rep Power
    184
    I do not think there is a way to dump the cache on an individual's browser; I think that would be an end user browser permission setting, that you cannot control. The only quick fix, that may work; would be to redirect your page with an unique query string; something along the lines of:
    Code:
    (function(){
    var here = window.location;
    if(!here.toString().match("updated")){
    window.location.replace(here + "?cache=updated");
    }
    })();
    And... in your updated pages; I would make sure I used cache controls, so this issue does not happen again.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2013
    Location
    Florianópolis, Santa Catarina
    Posts
    2
    Rep Power
    0

    Awesome!


    Originally Posted by web_loone08
    I do not think there is a way to dump the cache on an individual's browser; I think that would be an end user browser permission setting, that you cannot control. The only quick fix, that may work; would be to redirect your page with an unique query string; something along the lines of:
    Code:
    (function(){
    var here = window.location;
    if(!here.toString().match("updated")){
    window.location.replace(here + "?cache=updated");
    }
    })();
    And... in your updated pages; I would make sure I used cache controls, so this issue does not happen again.
    Hi you are awesome! Adding a parameter in the filename makes the browser request the same file again! Thank you, you saved my day! But I discovered that anoterh good aproach is not using the same name of the file to the library. I discovered it's better change the filename like jquery.min.1.9.js! It's better than upating only the content of the file! Your solution is great but I ended up changing the filename itself and I am also now using a CDN as you can see in my source code importing jquery http://www.sitepor500.com.br

    Comments on this post

    • web_loone08 agrees : Yeah, that's probably the best idea... to rename the external JS file, all together. You could also add a query string to the external JS file (similar to the redirect I posted for you); ...that works too. ;)
    Last edited by amandanovaes; August 7th, 2013 at 01:59 AM. Reason: adding another idea using CDN

IMN logo majestic logo threadwatch logo seochat tools logo