SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Thread: JS cache issue

  1. #1
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    JS cache issue

    Hi ,

    I am developing a section where we are going to host 1000's of videos. Now most of the site is going to be coded in ajax. So there are going to be several js files

    My question is , is it good t cache those js files so save time and make your page load faster? Those files are going to be change once a month, so can be put something in the headers to download it again if it was modified since last access time

  2. #2
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    My question is , is it good t cache those js files so save time and make your page load faster?
    Yes, indeed.
    so can be put something in the headers to download it again if it was modified since last access time
    One technique I've seen uses a version or date string, like this:
    Code:
    <script type='text/javascript' src='mysite/myscript.js?v=5dec06'></script>
    Now changing the value of 'v' will cause browsers to download the new 'myscript.js'.

  3. #3
    SitePoint Enthusiast
    Join Date
    Mar 2006
    Posts
    56
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HI,

    Thanks a lot for your reply....

    Actually this is the whole scenario to make you understand my problem in a better way...

    --------------------------------------------------------------

    My server is sending these headers

    post-check=0, must-revalidate, no-store, no-cache, pre-check=0

    Currently, i am caching gif images and css files. Only problem i see is that each time when i load my website it saves css file again the cache with new expiry date, that means it is not loading it from cache

    Initially i went to my home page and saw temporary internet file that said expiry date of my css is 1/3/2007 2:04 PM. After five minutes i refreshed my page again and the expiry date of my css was 1/3/2007 2:09 PM

    Please advice how can change my headers in htaccess so that each time the site opens it check if my css file is modified or not..If it was modified before the expiry then update the css file in cache otherwise just use the one in the cache

    i have a dyamic page but css and js script file hardly change. So what i exactly want is the header code, that checks for those css and js file, if they have been modified since last access time...

    If modified then copy the new file from the cache otherwise use it from the cache

    -------------------------------------------------------------------


    The solution that you gave, will still make it download every time i use the site. I want it to only download when it is modified otherwise use from cache

  4. #4
    I'll take mine raw silver trophy MikeFoster's Avatar
    Join Date
    Dec 2002
    Location
    Alabama, USA
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The solution that you gave, will still make it download every time i use the site.
    No, only when you change the date or version string. Besides, I thought your question was about Javascript. This is the Javascript forum.

    Search the forums, there are many discussions regarding your question - for example this one:
    http://www.sitepoint.com/forums/showthread.php?t=436701


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
  •