homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Visit PubCon.com
Home / Forums Index / Google / Google AdSense
Forum Library, Charter, Moderators: incrediBILL & jatar k & martinibuster

Google AdSense Forum

Caching, .htaccess and adsense question
Since adsense is Javascript, what is best practice with caching?

 10:14 pm on Jan 4, 2012 (gmt 0)

I am working on code for my .htaccess file to cache and speed up my site.

I have found a number of code examples out there, done different ways - but I am unsure on the best way to do javascript, since adsense is js.

The code I am talking about is:

<filesMatch "\.(js)$">
Header set Cache-Control "max-age=600, private"

My questions:
1) Is it safe to cache javascript if you use adsense
2) What is the best maximum age to cache javascript?
3) Should it be "private" or "public"
3) Is there anything that would pose a risk about this, or does it matter (regarding adsense)

In sum: What is best practice?

Just trying to be extra safe. Any feedback would be extremely appreciated. Thank you!



 10:31 pm on Jan 4, 2012 (gmt 0)

You don't host the AdSense js code so your cache has no control over this.

Google hosts the AdSense js, and in theory once the browser has loaded AdSense from Google it should have it in the browser cache itself for all subsequent loads from any website.


 10:58 pm on Jan 4, 2012 (gmt 0)

Thanks incrediBill. Does the same apply with compressing and gzip-ing with the .htaccess? I had read someone claim that because text compressing can remove comments that this could potentially modify adsense code, which is against TOS. Probably just being over-careful, but I just want to make sure I don't screw anything up. Thanks for your reply.


 11:14 pm on Jan 4, 2012 (gmt 0)

Sounds like you're listening to old AdSense wives tales, ignore those myths.

Compression doesn't remove comments, it only compresses them during transmission and they are decompressed on the receiving side. Google uses gzip themselves so I wouldn't be too worried about it.


 11:19 pm on Jan 4, 2012 (gmt 0)

you are right - there is a lot of crap out there that is mis-information and sometimes it's hard to know what's what - but I do always want to be super careful, which is why I asked.
You've been super helpful - thank you for your help!


 3:12 am on Jan 5, 2012 (gmt 0)

Ah, just remembered there are 'text compressing' programs out there too that reformat the actual HTML code on the page, totally different from gzip compression. The reformatting text compressors actually remove white space and comments from web pages to make them a few hundred bytes smaller, complete waste of time IMO, but those could potentially violate TOS by actually modifying AdSense code.

Those types of page reformatting routines I would avoid.

However, reformatting to save a few bytes isn't gzip. Gzip is a lossless data compression algorithm where data comes out the other end looking just like it did when it started, no changes.


 1:46 am on Jan 10, 2012 (gmt 0)

Thank you for posting your 'aha!' - that is really helpful to me. Since speed is such an issue now, it's good to look at all of the options out there.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Google / Google AdSense
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