Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

Ajax: decide on and add a "cache buster" option

#45

This will work simply by making the URI more unique with a randomized number similar to jQuery and others. This will be triggered if an option is set (defaults to on) and using GET.

Reported by Mark Caudill · July 16th, 2009 @ 08:28 AM

State: discuss
Milestone: none
Assigned to: John-David Dalton John-David Dalton

Activity

  1. Kit Goncharov
    Kit Goncharov
    • State changed from new to open

    Sounds good. I'd think just appending a unique ID to the end of the request would work, i.e.: key=value&key2=value2&_=1.

    I don't think the ID really has to be randomized — we could probably just declare var uniqueID = 1 in a closure, and then increment it every time an Ajax request is instantiated. jQuery uses +new Date() to create a unique ID — is there any benefit to using this over a basic incrementation?

    I'm not really sure if we need an option for this, though...

    July 16th, 2009 @ 04:23 PM

  2. Kit Goncharov
    Kit Goncharov
    • Tag changed from ajax to ajax, discuss

    July 16th, 2009 @ 09:01 PM

  3. John-David Dalton
    John-David Dalton

    I agree and I like the idea. I also saw jQuery messing with expire headers as well.
    I am for an Id based on time and an increment because if the user refreshes the page and we just used an increment they would get cached data.

    We could have a based on time and if a new id matches an old id
    (say multiple ajax calls at once), then we increment them so they don't match the last id.

    August 3rd, 2009 @ 11:25 AM

  4. John-David Dalton
    John-David Dalton

    Loads of info here https://developer.mozilla.org/En/Using_XMLHttpRequest

    important to this ticket is a section called "Bypassing the cache".

    August 3rd, 2009 @ 05:25 PM

  5. Mark Caudill
    Mark Caudill

    The only problem with loadFlags is that there is no way to test without doing a browser sniff. John seems he wants to avoid browser sniffs, so the ultimate solution may be what jQuery is doing (and Firefox recommends doing for cross-browser compatible in the link JDD gave). They just use the _ variable and replace the _ variable if it is already present. I think _ is too simple of a variable to take over, but that's just my opinion on that one.

    August 3rd, 2009 @ 07:15 PM

  6. John-David Dalton
    John-David Dalton

    We shouldn't use the _ underscore param because it causes issues with some environments.

    #9273 (Oracle App. Sever chokes on Ajax underscore parameter (Safari)) - Rails Trac - Trac

    Fuse actually removed the one that Prototype appends to its POST requests.
    The CHANGELOG entry explains it rather well.

    * Remove the "&_=" Safari 2 ajax bug workaround for the http PUT method. [Rails Trac #2258] [Prototype LH #327] [jddalton, Mark van Eijk, Shane Vitarana]
      Fixed in Rails by changeset http://dev.rubyonrails.org/changeset/2106.
    

    August 3rd, 2009 @ 10:13 PM

  7. Joe Gornick
    Joe Gornick
    • Milestone cleared.
    • Milestone order changed from 0 to 0

    September 19th, 2010 @ 05:51 PM

  8. Joe Gornick
    Joe Gornick
    • State changed from open to new
    • Assigned user changed from Mark Caudill to John-David Dalton

    September 29th, 2010 @ 09:47 AM

  9. Joe Gornick
    Joe Gornick
    • State changed from new to discuss
    • Tag changed from ajax, discuss to ajax
    • Milestone order changed from 3 to 0

    March 6th, 2011 @ 10:38 PM

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.