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

cache=1d

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:

cache=1w

To cache for 2 hours:

cache=2h


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.

Warning


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="http://mediacache.appspot.com/mediacache/lh5.ggpht.com/_N8htlFAQOes/RiDF79J1dGI/AAAAAAAAAFU/qZfwdyr6O6o/s800/100_1342.JPG?size=256&cache=42d"/>

Comments

Popular posts from this blog

Please use ANSI-92 SQL Join Syntax

the myth of asynchronous JDBC

The difference between Scalability, Performance, Efficiency, and Concurrency explained