Welcome Guest, Not a member yet? Register   Sign In
Google suggests caching images and other resources
#1

[eluser]skunkbad[/eluser]
I've got a Google webmaster tools account, and noticed that in the "Labs" area, there is a "Site Performance" tool. This tool makes suggestions, and one of them is to download the PageSpeed add-on for Firebug. I did that, and noticed that it was telling me that I should be letting the browser know how long to cache images and other resources. From my experience, browsers already cache the images and resources. Am I missing something? If I made all requests for images and resources go through a controller, and added a cache header, wouldn't this bog down the performance of my site compared to just serving up the image or resource?
#2

[eluser]BrianDHall[/eluser]
In a word - yes, it would slow things down to do it that way. I believe the only efficient way would be something like an htaccess solution, but questionable.

First, this is only good advice for really intense traffic sites - like Google. Similar to Yahoo's YSlow utility, it gives sometimes bad advice for regular websites, specifically regarding caching.

Yahoo, as a for instance, sets most of its pages and content to be cached forever. If they want to change or update something, they change the url. Facebook handles caching of included CSS and JS in their applications the same way - when you app submits a CSS or JS file they rip it out, do strange magical things to it, and cache it with the instruction that a browser should NEVER check for a new version. If you want a new version served you have to change the file of the file you submit to facebook.

These are all great ideas for massive sites, because lets say you have 20 files (a few JS and CSS pages, various little images, etc). Browsers occassionally check for a new version by pinging your server to see if they have a newer version of a given files.

You can use LiveHTTP Headers in firefox to see this traffic, and when it is generated. If you set cache directives some browsers will follow them to the letter, so they won't even ask your server if a newer version is available - it will assume it isn't until the cache expires.

This saves your server a few requests it has to deal with, a few hits to the file system. Most applications will have unnecessary bugs and added maintenance difficulty for no real benefit, but if you need to squeeze every last possible request out of your server because it is squealing for dear life - then caching is one thing to seriously look at.
#3

[eluser]Anthony Linton[/eluser]
I've often wondered about this, thank you for your detailed response!
#4

[eluser]skunkbad[/eluser]
Brian,

Thanks for your reply. I don't think I would pay full attention to Google's suggestions if Google wasn't saying that my site was loading slower than 65% of websites. I think what was killing the load time was the Statcounter stats tracking. I stopped using Statcounter, and Google is showing an immediate improvement in the Site Performance. I really like Statcounter, but I've noticed many times that it is holding up the page from loading completely. I'm going to have to create or find something that works better.
#5

[eluser]BrianDHall[/eluser]
Oh, now some of Google and Yahoo's advice can really be spot on, so certainly don't discount everything they say. They certainly know something Wink

Hm, slower than 65%? I'm both surprised that statcounter could cause such a problem, and yet not I suppose.

On that issue, have you tried Google Analytics? Resistance is futile - do not fight assimilation into the Borgle.
#6

[eluser]skunkbad[/eluser]
[quote author="BrianDHall" date="1261473956"]Oh, now some of Google and Yahoo's advice can really be spot on, so certainly don't discount everything they say. They certainly know something Wink

Hm, slower than 65%? I'm both surprised that statcounter could cause such a problem, and yet not I suppose.

On that issue, have you tried Google Analytics? Resistance is futile - do not fight assimilation into the Borgle.[/quote]

Yes, at one point I did try Google Analytics, but I just didn't like it. The information I could get from Statcounter on 1 page was better (for me) than what I could get with Google Analytics, which honestly wasn't as easy to use for me. Yes, there are some awesome Google services that I have used on my websites, but I won't be using Google Analytics. You might laugh, but I'm using Awestats and Webalizer at the moment! Built into cPanel. Who could ask for anything more? :-)




Theme © iAndrew 2016 - Forum software by © MyBB