<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Setting Static Asset Expires Headers with nginx and Passenger</title>
	<atom:link href="http://craigjolicoeur.com/blog/setting-static-asset-expires-headers-with-nginx-and-passenger/feed" rel="self" type="application/rss+xml" />
	<link>http://craigjolicoeur.com/blog/setting-static-asset-expires-headers-with-nginx-and-passenger</link>
	<description>code with a purpose</description>
	<lastBuildDate>Sat, 09 Jul 2011 15:49:38 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
	<item>
		<title>By: Craig</title>
		<link>http://craigjolicoeur.com/blog/setting-static-asset-expires-headers-with-nginx-and-passenger/comment-page-1#comment-26175</link>
		<dc:creator>Craig</dc:creator>
		<pubDate>Fri, 07 Jan 2011 20:25:51 +0000</pubDate>
		<guid isPermaLink="false">http://craigjolicoeur.com/blog/?p=125#comment-26175</guid>
		<description>@Francesco,

try something like the following to cache everything in /static

location ~ ^/static/</description>
		<content:encoded><![CDATA[<p>@Francesco,</p>
<p>try something like the following to cache everything in /static</p>
<p>location ~ ^/static/</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Francesco</title>
		<link>http://craigjolicoeur.com/blog/setting-static-asset-expires-headers-with-nginx-and-passenger/comment-page-1#comment-26174</link>
		<dc:creator>Francesco</dc:creator>
		<pubDate>Fri, 07 Jan 2011 20:16:09 +0000</pubDate>
		<guid isPermaLink="false">http://craigjolicoeur.com/blog/?p=125#comment-26174</guid>
		<description>How could I change the regexp of you example if I want that only the files contained in the /static directory are cached?</description>
		<content:encoded><![CDATA[<p>How could I change the regexp of you example if I want that only the files contained in the /static directory are cached?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig</title>
		<link>http://craigjolicoeur.com/blog/setting-static-asset-expires-headers-with-nginx-and-passenger/comment-page-1#comment-19419</link>
		<dc:creator>Craig</dc:creator>
		<pubDate>Thu, 26 Aug 2010 13:34:52 +0000</pubDate>
		<guid isPermaLink="false">http://craigjolicoeur.com/blog/?p=125#comment-19419</guid>
		<description>@Himanshu,

Just update the location regex map pattern to match the paths you want, in this case your /images directory.

You can also then set a rule specifically for logo.gif</description>
		<content:encoded><![CDATA[<p>@Himanshu,</p>
<p>Just update the location regex map pattern to match the paths you want, in this case your /images directory.</p>
<p>You can also then set a rule specifically for logo.gif</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Himanshu</title>
		<link>http://craigjolicoeur.com/blog/setting-static-asset-expires-headers-with-nginx-and-passenger/comment-page-1#comment-19412</link>
		<dc:creator>Himanshu</dc:creator>
		<pubDate>Thu, 26 Aug 2010 10:35:52 +0000</pubDate>
		<guid isPermaLink="false">http://craigjolicoeur.com/blog/?p=125#comment-19412</guid>
		<description>Hi,

How can I set different expire headers within a single location. For example in case of /images, I want the default expire time to be 1 hr except for logo.gif</description>
		<content:encoded><![CDATA[<p>Hi,</p>
<p>How can I set different expire headers within a single location. For example in case of /images, I want the default expire time to be 1 hr except for logo.gif</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig</title>
		<link>http://craigjolicoeur.com/blog/setting-static-asset-expires-headers-with-nginx-and-passenger/comment-page-1#comment-13188</link>
		<dc:creator>Craig</dc:creator>
		<pubDate>Fri, 13 Nov 2009 00:33:02 +0000</pubDate>
		<guid isPermaLink="false">http://craigjolicoeur.com/blog/?p=125#comment-13188</guid>
		<description>@eno,

Interesting.  I&#039;m wondering if this isn&#039;t an nginx version issue, because the regexp I use in the example works fine for me on my website.

But both you and Adam are saying the check against $location doesn&#039;t work, I&#039;m wondering if its because the $location variable changed in nginx.

what version are you running?  I&#039;m running version 0.6.36 on the server in question.</description>
		<content:encoded><![CDATA[<p>@eno,</p>
<p>Interesting.  I&#8217;m wondering if this isn&#8217;t an nginx version issue, because the regexp I use in the example works fine for me on my website.</p>
<p>But both you and Adam are saying the check against $location doesn&#8217;t work, I&#8217;m wondering if its because the $location variable changed in nginx.</p>
<p>what version are you running?  I&#8217;m running version 0.6.36 on the server in question.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eno</title>
		<link>http://craigjolicoeur.com/blog/setting-static-asset-expires-headers-with-nginx-and-passenger/comment-page-1#comment-13187</link>
		<dc:creator>eno</dc:creator>
		<pubDate>Fri, 13 Nov 2009 00:11:25 +0000</pubDate>
		<guid isPermaLink="false">http://craigjolicoeur.com/blog/?p=125#comment-13187</guid>
		<description>Hey craig, me again :) Hongli Lai&#039;s example does not work (as Adam already pointed out, because the location test does not include the URL arguments in the test against the regex. Adam&#039;s solution seems ok to me. My own setup is a bit different; if interested check it out here http://radiospiel.org/0x29-my-nginx-config.</description>
		<content:encoded><![CDATA[<p>Hey craig, me again :) Hongli Lai&#8217;s example does not work (as Adam already pointed out, because the location test does not include the URL arguments in the test against the regex. Adam&#8217;s solution seems ok to me. My own setup is a bit different; if interested check it out here <a href="http://radiospiel.org/0x29-my-nginx-config" rel="nofollow">http://radiospiel.org/0&#215;29-my-nginx-config</a>.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig</title>
		<link>http://craigjolicoeur.com/blog/setting-static-asset-expires-headers-with-nginx-and-passenger/comment-page-1#comment-12980</link>
		<dc:creator>Craig</dc:creator>
		<pubDate>Thu, 05 Nov 2009 21:19:35 +0000</pubDate>
		<guid isPermaLink="false">http://craigjolicoeur.com/blog/?p=125#comment-12980</guid>
		<description>@eno,

You are correct.  Good eye.

I&#039;ve gone ahead and updated the regexp in my example.</description>
		<content:encoded><![CDATA[<p>@eno,</p>
<p>You are correct.  Good eye.</p>
<p>I&#8217;ve gone ahead and updated the regexp in my example.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: eno</title>
		<link>http://craigjolicoeur.com/blog/setting-static-asset-expires-headers-with-nginx-and-passenger/comment-page-1#comment-12979</link>
		<dc:creator>eno</dc:creator>
		<pubDate>Thu, 05 Nov 2009 21:15:51 +0000</pubDate>
		<guid isPermaLink="false">http://craigjolicoeur.com/blog/?p=125#comment-12979</guid>
		<description>Hey craig, I think that your regexp doesn&#039;t match &quot;jpeg&quot; file extensions, but (wrongly) &quot;jg&quot;.</description>
		<content:encoded><![CDATA[<p>Hey craig, I think that your regexp doesn&#8217;t match &#8220;jpeg&#8221; file extensions, but (wrongly) &#8220;jg&#8221;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Craig</title>
		<link>http://craigjolicoeur.com/blog/setting-static-asset-expires-headers-with-nginx-and-passenger/comment-page-1#comment-10428</link>
		<dc:creator>Craig</dc:creator>
		<pubDate>Thu, 25 Jun 2009 15:41:41 +0000</pubDate>
		<guid isPermaLink="false">http://craigjolicoeur.com/blog/?p=125#comment-10428</guid>
		<description>Adam, my second regexp (the one I am actually using) does the same thing as your example.</description>
		<content:encoded><![CDATA[<p>Adam, my second regexp (the one I am actually using) does the same thing as your example.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Adam Byrtek</title>
		<link>http://craigjolicoeur.com/blog/setting-static-asset-expires-headers-with-nginx-and-passenger/comment-page-1#comment-10427</link>
		<dc:creator>Adam Byrtek</dc:creator>
		<pubDate>Thu, 25 Jun 2009 15:39:21 +0000</pubDate>
		<guid isPermaLink="false">http://craigjolicoeur.com/blog/?p=125#comment-10427</guid>
		<description>Your first regular expression doesn&#039;t match anything, as nginx doesn&#039;t include query string (part after the question mark) when matching location.

I prefer to set Expires *only* for assets with timestamp included, otherwise your users will have problems when you change the contents of a file without changing the name.

The following directive will cover this case:

location ~* \.(ico&#124;css&#124;js&#124;gif&#124;jp?g&#124;png) {
    if ($args ~* [0-9]+$) {
        expires max;
        break;            
    }        
}</description>
		<content:encoded><![CDATA[<p>Your first regular expression doesn&#8217;t match anything, as nginx doesn&#8217;t include query string (part after the question mark) when matching location.</p>
<p>I prefer to set Expires *only* for assets with timestamp included, otherwise your users will have problems when you change the contents of a file without changing the name.</p>
<p>The following directive will cover this case:</p>
<p>location ~* \.(ico|css|js|gif|jp?g|png) {<br />
    if ($args ~* [0-9]+$) {<br />
        expires max;<br />
        break;<br />
    }<br />
}</p>
]]></content:encoded>
	</item>
</channel>
</rss>

