Results 1 to 10 of 10

Thread: No Cache Iframe

  1. #1
    Join Date
    May 2006
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default No Cache Iframe

    I want to iframe/regularframe to an external site, but the external site is dynamic and changes alot. So how do i make an iframe or frame not cache so everytime the frame reloads itll be updated?

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

    Default

    Since the site inside the iframe is external, unfortunately you can't do anything to affect its cache settings. If the site was on your own server, you could, for example, use meta tags to specify the page's caching.

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

    Default

    Actually, that's not quite accurate.
    If you do something like, for example:
    Code:
    <iframe src="http://www.example.com/thepage.html" name="aframe"></iframe>
    <script type="text/javascript">
    document.frames['aframe'].location.href += (document.frames['aframe'].location.href.indexOf("?") != -1 ? "?" : "&") + (new Date()).getTime();
    </script>
    ... that should break caching in all Javascript-enabled browsers.

    However, it should be noted that this is a last resort only; if the external site's page changes regularly, they should have already taken server-side steps to assure that the cache is updated regularly.
    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!

  4. #4
    Join Date
    May 2006
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    Actually, that's not quite accurate.
    If you do something like, for example:
    Code:
    <iframe src="http://www.example.com/thepage.html" name="aframe"></iframe>
    <script type="text/javascript">
    document.frames['aframe'].location.href += (document.frames['aframe'].location.href.indexOf("?") != -1 ? "?" : "&") + (new Date()).getTime();
    </script>
    ... that should break caching in all Javascript-enabled browsers.

    However, it should be noted that this is a last resort only; if the external site's page changes regularly, they should have already taken server-side steps to assure that the cache is updated regularly.
    ehhhh...it didn't work. Check it out here: http://muson.susanasjewelry.com/forum/randomhelp.html .

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

    Default

    Ah yes Twey, I forgot about the "random number suffix" technique. How about this sartajc:

    Code:
    <script type="text/javascript">
    var randomnumber=Math.floor(Math.random()*100000)
    
    document.write('
    <iframe src="http://www.freedonation.com/hunger/hunger_thankyou.php3?random='+randomnumber+'" name="aframe" width="100%" height="400"></iframe>')
    
    </script>

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

    Default

    ... but that's JS-dependent. Also doesn't cater for GET variables (which are likely, since it is, to quote, a "dynamic" page).
    Use my code. I made three obvious mistakes, and probably about twenty subtle ones.
    Code:
    <iframe src="http://www.freedonation.com/hunger/hunger_thankyou.php3" style="width:100%;height:400px;" name="aframe"></iframe>
    <script type="text/javascript">
    var location = "http://www.freedonation.com/hunger/hunger_thankyou.php3";
    (document.frames || window.frames)['aframe'].location.href = location + (location.href.indexOf("?") == -1 ? "?" : "&") + (new Date()).getTime();
    </script>
    Last edited by Twey; 05-28-2006 at 08:08 PM.
    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!

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

    Default

    Well I thought I'd just throw the OP the line to get the fish. You're right, your code is more flexible though.

  8. #8
    Join Date
    May 2006
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    It worked....only in firefox. Not IE7. and most of the people that visit my site uses IE (grrrrr. i wish they used firefox. its so much better).

    check it out here: http://muson.susanasjewelry.com/forum/help.htm .
    Look what it does in firefox, and what it does in IE. actually does something in firefox, but does nothing in IE.

    i used both ddadmins and tweys code. why won't it work in IE? (of course nothing works in IE )

    oh yeah, i dont have to use iframe. regular frame, php, or anything else will work. as long as it works.

    btw, theres millions of tech forums, but this one is the best one i have encountered.

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

    Default

    For me it works in IE (v6). Firefox... what on earth?!
    Ah... try this one:
    Code:
    <iframe src="http://www.freedonation.com/hunger/hunger_thankyou.php3" style="width:100%;height:400px;" name="aframe"></iframe>
    <script type="text/javascript">
    var dokoka = "http://www.freedonation.com/hunger/hunger_thankyou.php3";
    (document.frames || window.frames)['aframe'].location.href = dokoka + (dokoka.href.indexOf("?") == -1 ? "?" : "&") + (new Date()).getTime();
    </script>
    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!

  10. #10
    Join Date
    May 2006
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Twey
    For me it works in IE (v6). Firefox... what on earth?!
    Ah... try this one:
    Code:
    <iframe src="http://www.freedonation.com/hunger/hunger_thankyou.php3" style="width:100%;height:400px;" name="aframe"></iframe>
    <script type="text/javascript">
    var dokoka = "http://www.freedonation.com/hunger/hunger_thankyou.php3";
    (document.frames || window.frames)['aframe'].location.href = dokoka + (dokoka.href.indexOf("?") == -1 ? "?" : "&") + (new Date()).getTime();
    </script>

    Thank You! it worked in IE7! but now its not working in firefox...HOWEVER. thats not a problem. Ill just run both scripts! Thanx a lot! ill link back to this site!

    check out the double iframe thingy here: http://muson.susanasjewelry.com/forum/rand.htm
    Last edited by sartajc; 05-29-2006 at 11:29 PM.

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
  •