Has anyone successfully implemented rails page caching with subdomains?
Right now the same file is being served up between subdomains as rails does not recognize the fact that the subdomain has changed.
I'd like my page caches to look something like this:
/public/cache/subdomain1/index.html
/public/cache/subdomain1/page2.html
/public/cache/subdomain2/index.html
/public/cache/subdomain2/page2.html
I'm using nginx for serving up these pages so will need to change it's config file to find these files once they're cached, that won't be a problem. The sticking point for me at the moment is on the rails end.
I used this guy's post (with a few modifications)
Then just use the usual caches_page class method.
The downfall of this is that, I need to hack the expire_page as well (which was not mentioned in the post). Also Rails won't use existing page cache if it exists, since it won't find it in the default path.
You need to update the cache location based on which subdomain is in use.
You can add a
before_filter
to do this.An example would be: