What does mod_pagespeed do?

Pratik picture Pratik · Feb 3, 2011 · Viewed 8k times · Source

This is with reference to:

http://googlecode.blogspot.com/2011/01/go-daddy-makes-web-faster-by-enabling.html

But I still don't know how it works the in background to dynamically optimize pages.

One more thing I could NOT understand why "Cached subsequent requests are slow" ?

enter image description here

Answer

miki725 picture miki725 · Feb 3, 2011

PageSpeed mod_pagespeed is a module for Apache server which is just like a plug in, and since Apache is different from IIS, it cannot be installed on IIS servers.

As for what it does, it does multiple things:

  • Minifies (removes whitespace, comments, etc) or in other words compresses external CSS and JavaScript
  • In addition to minifying JS, it combines multiple external JS files into one JS file which causes less http requests or round trips so the page loads faster
  • Optimizes the cache for the files. Every http header has a cache information, or in other words, for how long should the browser keep the resource, mod_pagespeed optimizes this number
  • Uses the idea of URL fingerprinting for the new JS files. Basically when the mod_pagespeed optimizes and combines multiple JS files into one file, this temporary file is stored somewhere on the server, however, its filename is generated from the content of the JS files using checksum algorithms such as MD5. What this allows to do is that mod_pagespeed tells the browser to store the JS file for a long time (sets a long cache time), however as soon, as the developer will change the content even in one of the JS files, since the checksum of all the files will change, mod_pagespeed will generate a new temp JS file which will have a different URL compared to the old one. So, when the user who has saved the old combined JS file will try to reload the page, since the URL of the new JS file will be new, it will force the browser to download it again. So essentially this is one way to do cache control.
  • Minifies HTML

So this module is pretty cool. It can really speed up the performance of the sites. One downside however is that it uses much more CPU resources on the servers.

Hope this helps.