Script to quickly reload html page

Discussion in 'JavaScript' started by duneglow, Oct 21, 2011.

  1. #1
    I'm in need of a solution perhaps with javascript to pre cache my web page content. which is basically 8 swf files. I need these to load into the browser prior to the page being served.
    I understand that the best solution would be with preloders wthin the swf files themselves but I've been through this already with flash developers and that has not helped.
    I tested with html code that reloads the page and that did the trick but that problem was that the code went into an infinite loop reloading the page everytime and I need a solution
    that reloads the page just ones and I mean just reload and not refresh because I'm not looking for fresh content but the old content is what I need to stay in the cache.
    any help would be appreciated. This issue is driving crazy. :(

    duneglow
     
    duneglow, Oct 21, 2011 IP
  2. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #2
    1) Refresh and reload are the same thing. One is done by the user, one by the page itself.

    2) You can't have a page reload itself, because you'll go into a reload loop, unless you save the session, page and a flag that it's been reloaded.

    3) Try using caching on the site.
     
    Rukbat, Oct 21, 2011 IP
  3. gumape

    gumape Peon

    Messages:
    30
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    If your page contains 8 large swf files and you don't want that your visitor's browser downloads them on every visit, just set expires headers for the swf files on server side. In that case, the swf files need to be downloaded only the first time.
    If this solution is not convenient for you and you really need page reload, use JavaScript Storage objects (see: https://developer.mozilla.org/en/DOM/Storage) to store whether it is the first reload or not.
     
    gumape, Oct 21, 2011 IP
  4. karius

    karius Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    how to do that??
     
    karius, Oct 22, 2011 IP
  5. Rukbat

    Rukbat Well-Known Member

    Messages:
    2,908
    Likes Received:
    37
    Best Answers:
    51
    Trophy Points:
    125
    #5
    That depends on whether you're using a CMS, which one you're using (i you use one) and what your host has available.

    BTW, "prior to the page being served" - nothing happens. Everything is triggered by the page being served.
     
    Rukbat, Oct 24, 2011 IP
  6. ustas19

    ustas19 Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Maybe you should load this files in background after page loaded and rendered?

    F.e. use onload event and load this files in hiddne div(div style display:none???)

    try window.onload=function(){} or if you use jquery $(function (){your code here})
     
    ustas19, Oct 24, 2011 IP
  7. ustas19

    ustas19 Peon

    Messages:
    26
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Also specify expires header, it mean that not expired content dosn't download every time when user open or reload page.

    read about mod_expires in apache manual.
     
    ustas19, Nov 14, 2011 IP