[Melbourne-pm] Apache Cache
mathew.robertson at netratings.com.au
Mon Jul 3 23:13:05 PDT 2006
>> As to the origonal problem -> we want thumbnails, thus caching was
>> suggested. Why caching? What is the problem that we are trying to
>> solve? To generate smaller images automatically?
> The original problem - YES - the extended problem - NO - the question
> was - is there a standard way of using caches in Apache, as it seems
> every module does its own thing - in this particular case I don't think
> I should use a cache API. Explanation...
> For Thumbnails - most likely: (n hours is configurable)
> * Create image with reasonable expiry (e.g. n hour)
> * On a request for IMS (if mod since) - pass it through to the
> subrequest (i.e. leave it to the original file)
> (this may be inefficient - might make it configurable)
> * On new request get local file, if modified longer than n hours,
> then check headers of original file
> * If out of date - regenerate, write to disk
> * If in date - redirect to local file and update expiry
> * Note: check the pragma nocache and expiry of original and inherit
> if smaller (for generated objects).
> Nice thing about the solution above is that the cache is just files on
> the disk sure, but it is then using Apache to do all the hard work. And
> Apache is already insanely fast at providing files.
> The only work it is therefore doing is checking some dates and
> generating the thumbnail if it must.
> By checking pragma and expiry it covers the cases when thumbnails can't
> be cached (e.g. generated on the fly).
> HOWEVER... If I write code that always generates the thumbnail from the
> original, and plug in mod_cache in front - it is the same thing :-)
> mod_cache already does almost all of the above.
As you just said, in this example caching buys you nothing as Apache
can already serve the files quite fast.
I guess what I was asking was, why cache at all? What is it that
you are trying to do with the cache?
- Reduce CPU load when the inbound request asks for a thumbnail, by
pre-generating the thumbnails, rather than loading the origonal file
then making a temporary thumbnail? (The original question sounded
like it might be this.)
- Are you trying to save bandwidth by sending smaller files?
Can you not cache? ie: when you upload the image, you generate a
thumbnail there and then - no caching needed.
More information about the Melbourne-pm