Results 1 to 6 of 6

Thread: ajaxcontent caching

  1. #1
    Join Date
    Mar 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default ajaxcontent caching

    http://www.dynamicdrive.com/dynamici...jaxcontent.htm
    Experimenting with the above script, I find that changes I make to the external file I am loading into my page, are not being seen. It seems that the function is “remembering” not only my CSS file, but also the external page. My javascript ability is not so good, so I am asking if my external files are also being “remembered”, similarly to that noted in the extract below.

    “Also, this function (loadobjs) will remember when a CSS or JS file has already been loaded and applied to the page, and won't load the same file again even if the link that invokes it is clicked on multiple times. This is for sake of efficiency.”

    I also have some corrections to make with my CSS, which becomes very time consuming, because of this caching. What's the best way to temporarily disable it ?

    Thanks
    Alan

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Configure your server to not cache the page(s) in question. However, enable it again once you're done testing; caching is useful and shouldn't be disabled.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Aug 2004
    Posts
    9,903
    Thanks
    3
    Thanked 967 Times in 955 Posts
    Blog Entries
    15

    Default

    See this thread for a solution: http://www.dynamicdrive.com/forums/s...ead.php?t=8172

    BTW, I think I'll just go ahead and add anti caching to the script right now, since it seems to be what people want.

  4. #4
    Join Date
    Mar 2006
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Works a treat !! Thanks. Great support.

    I guess in a working environment, the script could check the timestamp of the external file, and download it again only if it is newer than the cached file, or would this be too inefficient ?

    Alan

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,878
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I guess in a working environment, the script could check the timestamp of the external file, and download it again only if it is newer than the cached file, or would this be too inefficient ?
    That's what the original script does.

    ddadmin: I think this ought to be a variable.
    Also, check for data transferred via the GET URI, because this could mess up operation otherwise:
    Code:
    page_request.open('GET', url + (url.indexOf('?') == -1) ? '?' : '&') + 'bustcache=' + (new Date()).getTime(), true)
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Aug 2004
    Posts
    9,903
    Thanks
    3
    Thanked 967 Times in 955 Posts
    Blog Entries
    15

    Default

    Good point Twey. I've gone ahead and added bust caching as a variable:

    Code:
    if (bustcachevar) //if bust caching of external page
    var bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
    page_request.open('GET', url+bustcacheparameter, true)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •