Sunday, January 17, 2010

media cache (with caching)

I supposed the title of my previous post was a little bit misleading. The original (OK version 2) of that code actually didn't cache anything, but just acted as a reverse proxy to resize images.

I added some code to perform some rudimentary caching. You can now add


to have the browser cache the image on the local disk for 1 day. Similarly there are other combinations:.
To cache for 1 week add:


To cache for 2 hours:


What this means is that after the browser initially loads the image it will hold it on disk and not request it again for the amount of time that was specified. This doesn't apply if the user hits "reload", but works great for normal navigation.


This means users won't see a new copy of the image unless they explicitly hit "reload". You may need to use unique urls for changes to images once you start do this.

example (cache for 42days and resize to 256x256:

<img src=""/>

No comments: