Google page speed, caching and HTTP headers

lanmenz
lanmenz used Ask the Experts™
on
I think page speed is gaining in importance with search engines (and always important for users!)  so I'm keen to ensure that all my sites are optimised for speed.

There's a few new tools around (e.g. Google's page speed analyzer) that help to identify potential issues, but I've been unable to find any clear direction on how to resolve certain issues and what is considered best practice.

Firstly the 'Leverage browser caching' recommendation from Google's page speed analyzer - it's easy enough to set this up on pages, but how is caching achieved for image files?

Also with regards to setting an expiration date Google recommends "Specify an expiration at least one month in the future for resources that should be cached, and an expiration in the past for resources that should not be cached".

Historically many people prevented caching:

<meta http-equiv="Pragma" content="no-cache" />
<meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
<meta http-equiv="Expires" content="-1" />

to force SE's to download a fresh copy of the page, but is this bad practice now, will it slow page load times?

If caching is not prevented what should the expiry be set to for important pages such as the homepage which should be cached, but will change on a weekly basis?

Would be most grateful for some guidance on these issues.

Cheers.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Joshua TitsworthDigital Marketing Specialist
Commented:
>If caching is not prevented what should the expiry be set to for important pages such as the homepage which should be cached, but will change on a weekly basis?

Then I would set the expiration on the homepage to the date you intend to update the information on.

>to force SE's to download a fresh copy of the page, but is this bad practice now, will it slow page load times?

Since this isn't a good thing to do, I'd stay away from it.

>but how is caching achieved for image files?

Files like javascript, css, images are not saved by Google. If a website removes one of the previously mentioned files for instance, and the old version is viewed in google's cache, it will appear without the file or in this case images.
There are various ways to set headers but the easiest way is in Apache or .htaccess using expiresbytype

Here is a very good example

http://snipplr.com/view/4265/cache-control-with-htaccess-expires-by-type/

Other solutions are less flexible specifying a fixed future date

Browser caching is totally different to the frequency of Google indexing -

It is good practice to send a last modified which Apache does by default

With page speed, Google is looking at every element on a page, including images, time to execute and render Javascript etc. My blog for instance currently earns terrible load times within webmaster tools, but the primary culprit is Google's own Friend Connect widget which I will soon be dumping.

Commented:
If you want another tool for comparison, Yahoo has a plugin for Firefox (requires Firebug plugin) that analyzes web page performance.

http://developer.yahoo.com/yslow/

Google Chrome also has a Resources feature built in to it's Developer Tools.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial