Caching of Feeds

Oh hai!

I was wondering why the suggested nginx configuration prevents URLs containing “/feed/” from being cached. According to my access logs and a quick look at the code, these URLs are in fact purged, and while someone in this thread suggested removing the purging code, I would much rather do the opposite and allow feeds to be cached. Just the explicit exclusion in the sample config leads me to think that I may be overlooking a crucial problem with that approach.

# Don't cache uris containing the following segments  
if ($request_uri ~* "(/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") {  
    set $no_cache 1;  

We have many readers who request our feeds frequently, so that almost 30% of the requests handled my Wordpress (cache notwithstanding) are requests for various feeds. The comment feeds of older posts hardly ever change anymore, and with just a few posts and updates per day, the main feeds would greatly benefit from caching as well.

Are there any hidden hazards in just removing the “|/feed/” part from the regular expression?

Many thanks in advance,


I noticed a problem. While …/feed/ is purged, …/feed/atom/ isn’t, and purging multiple location at once in nginx is not yet supported.

If it’s just a matter of adding another line here, I can provide a pull request.


Feeds are cached to reduce loads. Feeds generally see non-human traffic from search engines, RSS readers, aggregators, etc.

Most WordPress caching plugins will refresh feed content as soon as a post is published/edited so you no need to worry about visitor getting stale content.

Regarding this issue, we are not developer of that nginx-module so I cannot tell you anything about pull-request.

But if you are using nginx-helper WordPress plugin, feel free to send pull requests (if you have any).

Oh yes, sorry, I’m using the nginx-helper plugin and nginx FastCGI caching. Maybe I should’ve pointed that out.

I forgot to mention yesterday that I also filed this pull request. I’ve applied it to our sites; let’s hope nothing explodes.

Thanks for your pull-request. :-)

We will merge it and test it locally soon. If all works nicely, we will add & release it.

If you have account on, can you tell us your username there. So we can credit you as contributor in next release (assuming this will work nicely) ;-)

Cool, thanks!

(I didn’t have an account, but now I do.)


Your work is already released - :-)

Yep, thankies! I already updated both sites earlier. :‑)

Hi guys!

So, if I get this right Nginx Helper is actually purging all the feeds. But the config tells Nginx to bypass all the feeds?

# Don't cache uris containing the following segments
if ($request_uri ~* "/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") {
	set $skip_cache 1;

So I’d only need to remove /feed/ from there and It’ll automagically cache+purge, right?