It is possible to force PageSpeed to generate an ajax-loaded image at a smaller sizes using a manually written pagespeed resource url as follows:
Original image url:
100x100 thumbnail: (thumbnail is not generated until first reload)
http://www.modpagespeed.com/images/100x100xPuzzle.jpg.pagespeed.ic.0.jpg
This works fine, however the thumbnail will not stay in the cache because it does not have a valid PageSpeed hash at the end of the url(I'm using 0
as the hash in the example above.
Is it possible to generate a valid hash using php or otherwise, which we can use to enable caching for this resource? How does mod_pagespeed
generate the hashes?
From a PageSpeed representative on Google Groups:
Sorry, the only way to generate a valid hash is for PageSpeed to generate the optimized image link itself. The main problem is that PageSpeed may not optimize the image completely on the first request, so if it responded to
myImage.jpg?compress=1&size=100x100
with longcache headers then it could poison caches with unoptimized resources.
It's a real shame because using this technique would be a quick and simple way to create a powerful, manually controllable image caching system.