homepage Welcome to WebmasterWorld Guest from 54.235.39.132
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Visit PubCon.com
Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
Forum Library, Charter, Moderator: open

JavaScript and AJAX Forum

    
IFrame Cache Issue,
TeoFriendly




msg:4459374
 10:37 am on May 30, 2012 (gmt 0)

Hi.
I have a small ad network. Its invocation codes are iframe.
The issue is that, if the publisher pastes the ad code more than one place in the same page, then there is issue with opera.

Opera loads the first iframe from the server, then loads others from cache, So all ad boxes shows the same ads.

However other browser are fine.
In Chrome, IE and FireFox, there is no problem. They show different ads in each box.

Please open this page with opera and other browsers to see the difference.

pastehtml.com/view/bzsofpi67.html

How can i prevent this opera iframe caching ?

Regards.



 

Fotiman




msg:4459419
 1:24 pm on May 30, 2012 (gmt 0)

Welcome to WebmasterWorld!
Not really a JavaScript question, unless you're using JavaScript to output the iframes. If you were, then you could use JavaScript to generate a random number and append it to the querystring of URL in the iframe, thus ensuring that the request is unique, forcing the browser to fetch the page again.

I suspect, though, that the page that gets loaded in the iframe should have some HTTP headers set to prevent it from being cached. For example:

<?php
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
?>

Hope that helps.

TeoFriendly




msg:4459470
 2:36 pm on May 30, 2012 (gmt 0)

Thanks.
The urls are static unfortunately.
Have you look at the adress above? The Issue is in Opera only. Other browsers are fine.
The page gets loaded is work.php, I added the code you provided to that page, but did not help. (May be i did not add it correctly)

Here is the my HTTP Header for the Pages which are loaded in IFrame.

http://banner.****ireklam.com/work.php?n=2&size=3&j=1&c=&code=1338387311039

GET [banner.****ireklam.com...] HTTP/1.1
Host: banner.***ireklam.com
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:12.0) Gecko/20100101 Firefox/12.0
Accept: */*
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Proxy-Connection: keep-alive
Referer: [****ws-az.com...]
Cookie: PHPSESSID=90b11d1ebe5848273d8e9280c082756e

HTTP/1.0 200 OK
Date: Wed, 30 May 2012 14:27:25 GMT
Server: Apache
X-Powered-By: PHP/5.2.17
Expires: Thu, 19 Nov 1981 08:52:00 GMT, Wed, 11 Jan 1984 05:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0, no-cache, no-store, must-revalidate
Pragma: no-cache, no-cache
Content-Type: text/html
X-Cache: MISS from x.vpsb6317a39.com
Via: 1.1 x.vpsb6317a39.com:80 (squid/2.7.STABLE9)
Connection: close


Isnt it ok ?
Regards.

Fotiman




msg:4459475
 2:48 pm on May 30, 2012 (gmt 0)

That looks correct to me (I see the Cache-Control and Expires headers in your response). The first thing I would suggest would be to empty Opera's cache, and then try it again. If you get the same results, then I'm sure Opera has some developer tools that allows you to view the request/responses, so I would check that to see that Opera is getting a 200/OK for each request (and is not getting a 304). I don't use Opera, so I can't offer much advice as to how to do this.

TeoFriendly




msg:4459502
 3:27 pm on May 30, 2012 (gmt 0)

Here is the header of the Opera.

URL = [banner.***ireklam.com...]
NameValue
Status200
Status TextOK
DateWed, 30 May 2012 15:21:05 GMT
ServerApache
X-Powered-ByPHP/5.2.17
ExpiresThu, 19 Nov 1981 08:52:00 GMT, Wed, 11 Jan 1984 05:00:00 GMT
ExpiresWed, 11 Jan 1984 05:00:00 GMT
Cache-Controlno-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0, no-cache, no-store, must-revalidate
Cache-Controlmax-age=0, no-cache, no-store, must-revalidate
Pragmano-cache, no-cache
Connectionclose
Content-Typetext/html


Well, the issue is that, i have placed the the same iframe 3 times on the same page.

So opera does not take care of expiry date.

If i reload the page, opera will reload the iframe from the server, not from the cache.

But when there is 3 same iframe in the same page, it unfortunately reload only the first one, other comes from the cache.

I dont know whether something could be done with the help of javascript. May be we can add javascript somewhere for each iframe tags, so it force them to reload?
Regards.

Fotiman




msg:4459511
 3:46 pm on May 30, 2012 (gmt 0)

For a static page, you could try modifying the markup to include a unique value in the query string even though that value is not used on the server. For example:

<iframe src="http://example.com/work.php?n=2&size=3&j=1&c=&code=1338387311039&ck=1">

<iframe src="http://example.com/work.php?n=2&size=3&j=1&c=&code=1338387311039&ck=2">

<iframe src="http://example.com/work.php?n=2&size=3&j=1&c=&code=1338387311039&ck=3">

This *should* force the browser to send separate requests for each.

TeoFriendly




msg:4459514
 4:05 pm on May 30, 2012 (gmt 0)

Yep. You are right.
If i cant find a solution, i will do like that.
The script owner is a kind man, who already told that solution.

But i wanted to know, if we cant use any jquery or something like that, to force reload, or something like that.
Because for my users it may be difficult to make changes in the url or so on. That is the reason.

Regards/

Fotiman




msg:4459525
 4:42 pm on May 30, 2012 (gmt 0)

Well, there are JavaScript options, however, they will not be as reliable because visitors with JavaScript disabled will not have the same experience. But you could use JavaScript to set the src on the iframe, and add the dynamic value to the querystring.

TeoFriendly




msg:4459531
 4:48 pm on May 30, 2012 (gmt 0)

Great,
Then i will need to modify the php files for it ?
Or adding the javascript near to invocation code is enough ?
Regards.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / JavaScript and AJAX
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved