Rails + Caching + XML = Bad Mime Types
So I’ve started working on a replacement RSS feed for the blog. It’s not really a drastic change, just a few little add-ons and a move internally from ERb templates to Builder templates. I’m also working very hard to have it so the feed is cached on the file system, and thus enabling Apache to give a 304 (nothing has changed) message. (Currently it give a 200 OK message and every byte, for every request.)
My problem is this: When I tell the
caches_page :fastrss it ends up using a
.html file extension on the file it creates, then Apache servers it with a
text/html mime type, then the feed validator rightfully complains. What I need to do is figure out how to tell the cache system to use a .xml for just that method on the blog controller, and then figure out how to edit the Apache
.htaccess file to look for the
.xml file before handing over the request to the dispatcher.
To be honest I was hoping the cache system would have noticed I was using Builder and used the
.xml extension automatically. It just seems like something Rails would have done. Maybe I expect to much. Anyways, I’ve done a fair amount of Googling but have yet to find a solution that felt right. I have to imaging others out there have solved this. If you can help please let me know.
/blog/fastrss/ feed is only temporary. Once I work out these issues it will disappear and replace the the current RSS implementation.
Posted on: February 17, 2006 – 10:59 PM