Using memcache and file caching at the same time

Bill,
I have a similar problem.

I am using page caching for my RSS feed.

I think once I run mongrels in a clustered of machines, I'd have
problems with page caching because the page caching can't be expired on
all machines automatically.

Can you give me a solution for solving this problem?

Thanks.
Yaxm

Bill Horsman wrote:

Hi Yaxm,

Can you explain how your problem is similar? Mine was that I was wanting
to mix file caching with memcache. My solution was to not do so! For the
record, I'm much happier now that I'm storing my images on the
filesystem anyway.

I haven't needed to get page caching working with memcache yet, but I do
foresee needing to do so. At the moment, I just cache models explicitly.
I'll try and remember to post my experience here when I come across a
solution.

Cheers,
Bill

Bill?

Do you cache and expire images in file system?

When you run mongrels on different servers,
do you cache images on a particular server?
if you cache images on all servers, would you need to expire cached
images on all servers?

Bill Horsman wrote:

Yaxm Yaxm wrote:

Do you cache and expire images in file system?

I don't really cache them. The file system is the store. They're not
stored anywhere else. The database just has a reference to the file
name.

When you run mongrels on different servers,

Yes.

do you cache images on a particular server?

Yes. My setup is Apache load balancing to a cluster of Mongrels spread
over two machines. I've configured Apache to serve all static content
directly so it doesn't even involve the cluster.

The only tricky bit is when Rails updates an image (for instance, if a
user uploads a new one) I have to make sure it uses a "local" Mongrel
instance on the same machine. Snippet from my httpd.conf:

# Direct all image uploads to local Mongrel instance
RewriteRule /upload_an_image_path/(.*)$
http://127.0.0.1:3000%{REQUEST_URI} [P,QSA,L]
[snip]
# Rewrite all non-static requests to cluster
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
# This is where file_column stores images
RewriteCond /home/me/images/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://mongrel_clusterA%{REQUEST_URI} [P,QSA,L]

- Bill