I’m in search of myself. Have you seen me?
I’m in search of myself. Have you seen me?
A Little Drupal RSS TipI noticed that Mac Geekery and codepoetry’s most-pulled files were RSS feeds. I’ve known that for a while, but just noticed it today. Funny that. So then I got to thinking about this fact and realized that for every pull of the feed (without caching) there’s a few dozen queries to be had. Even with caching there’s at least one query to be had. When you get 50K pulls of an RSS feed, that’s a lot of useless queries. So, what follows is how to make a dynamic page static and updated so that Apache can do what it does best: send a static file. As-is, the default rewrite rules for Drupal employ a basic test: let Apache send requests that exist, try to create requests that don’t. So, to get a static page in, just make the file exist. I used
Okay, so now I have my own static feed. To make Drupal point people to this, I made a path alias from What do I do about the thousands of RSS subscribers? Apache can do this, easily. I added the following rules to Mac Geekery’s configuration right above Drupal’s rewrite rules:
What this means, if you’ve never looked at rewrite rules before, is that only connections from IPs starting with 127 will get the real So, existing users get a redirect to the new location, new users get pointed to that location, cron makes sure the file is updated, and I’ve saved myself a few thousand SQL queries a day. Woo. For extra points, I’m caching the blog feed in a few minutes, and then codepoetry’s feed. Now, a curiosity: only NetNewsWire appears to automatically update itself when it gets a 301 response. Everyone else is either breaking or following the redirects every time. Rah rah to Ranchero, shame on everyone else. |
|
Post new comment