<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
	<channel>
		<title><![CDATA[Rails Forum - Ruby on Rails Help and Discussion Forum - Cached files not being 'seen' after changing page_cache_directory]]></title>
		<link>http://railsforum.com/viewtopic.php?id=11033</link>
		<description><![CDATA[The most recent posts in Cached files not being 'seen' after changing page_cache_directory.]]></description>
		<lastBuildDate>Thu, 15 Jul 2010 09:18:23 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: Cached files not being 'seen' after changing page_cache_directory]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=127866#p127866</link>
			<description><![CDATA[<p>Thanks jzwolak; I spent 2 hours playing around with mod_rewrite on my server yesterday before finally giving in and resigning myself to the fact I&#039;d have to add all the cached files in /public to .gitignore instead. I just tried your ruleset and it worked perfectly first time <img src="http://railsforum.com/img/smilies/smile.png" width="15" height="15" alt="smile" /></p>]]></description>
			<author><![CDATA[dummy@example.com (ss)]]></author>
			<pubDate>Thu, 15 Jul 2010 09:18:23 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=127866#p127866</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cached files not being 'seen' after changing page_cache_directory]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=117320#p117320</link>
			<description><![CDATA[<p>Okay, after 2 days of work, I figured out how to create an htaccess file to complement changes to page_cache_directory.&nbsp; This will allow Apache to find cached pages using Rails builtin page caching (not action caching or fragment caching.&nbsp; Without a proper htaccess file either Apache cannot find the cached pages or the rewrite rules will interfere with Rails routes in the routes.rb file.</p><p>This solution has been tested with passenger on my website hosted at railsplayground.com.</p><p>Here is the final product:</p><div class="codebox"><pre><code>RewriteEngine On

RewriteCond %{REQUEST_URI} ^([^.]+)/$
RewriteRule ^[^.]+/$ /%1 [QSA,L]

RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{REQUEST_URI} ^([^.]+)$
RewriteCond %{DOCUMENT_ROOT}/cache/%1.html -f
RewriteRule ^[^.]+$ /cache/%1.html [QSA,L]

RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}/cache/index.html -f
RewriteRule ^$ /cache/index.html [QSA,L]</code></pre></div>]]></description>
			<author><![CDATA[dummy@example.com (jzwolak)]]></author>
			<pubDate>Tue, 26 Jan 2010 18:14:15 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=117320#p117320</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cached files not being 'seen' after changing page_cache_directory]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=117319#p117319</link>
			<description><![CDATA[<p>Those rewrite rules need some modifications to work correctly.&nbsp; Something like this in your htaccess file will work a bit better, but still needs improvement:</p><div class="codebox"><pre><code>RewriteEngine On
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{REQUEST_URI} ^([^.]+)/?$
RewriteCond %{DOCUMENT_ROOT}/cache/%1.html -f
RewriteRule ^[^.]+/?$ /cache/%1.html [QSA,L]

RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}/cache/index.html -f
RewriteRule ^$ /cache/index.html [QSA,L]</code></pre></div><p>This won&#039;t work if you have trailing slashes, but it works in other cases.</p>]]></description>
			<author><![CDATA[dummy@example.com (jzwolak)]]></author>
			<pubDate>Tue, 26 Jan 2010 18:01:10 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=117319#p117319</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cached files not being 'seen' after changing page_cache_directory]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=50578#p50578</link>
			<description><![CDATA[<p>You need to add the leading &quot;/&quot; for Apache.&nbsp; This took me a while to figure out!</p><p><pre name="code" class="ruby:nogutter">RewriteRule ^$ /cache/index.html [QSA]<br />RewriteRule ^([^.]+)$ /cache/$1.html [QSA]</pre><br /></p><div class="quotebox"><cite>cbit wrote:</cite><blockquote><p>Hi ryan. Yes its page caching i&#039;m using, thanks for the clarification.</p><p>On my production server Apache is used as the front end. Am i correct in thinking that the following code (in .htaccess) is sufficient for the custom cache directory setup to work properly in that environment?:<pre name="code" class="ruby:nogutter">RewriteRule ^$ cache/index.html [QSA]<br />RewriteRule ^([^.]+)$ cache/$1.html [QSA]</pre><br />If so then i guess its just my local mongrel configuration that needs changing then so that caching works when i run the site on my development machine too.</p></blockquote></div>]]></description>
			<author><![CDATA[dummy@example.com (yaxm)]]></author>
			<pubDate>Sun, 13 Jan 2008 07:58:42 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=50578#p50578</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cached files not being 'seen' after changing page_cache_directory]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=39912#p39912</link>
			<description><![CDATA[<p>I think I&#039;m having this exact same issue, only with fragment caching. On edge:</p><p><pre name="code" class="ruby:nogutter">&lt;% cache :controller =&gt; &quot;base&quot;, :action =&gt; &quot;foo_bar&quot; do %&gt;<br />Do fancy stuff!<br />&lt;% end %&gt;</pre><br />After a while - I haven&#039;t isolated exactly what causes it - rails starts ignoring the expired caches and just keeps some old version instead. I _think_ it&#039;s related to conflicts with a routing namespace I have. Not sure tho&#039;.</p><p>I have never ever cached before, though, completely beginner on this. I might just oversee some basics.</p><p>This is with nginx proxying to mongrel, btw.</p>]]></description>
			<author><![CDATA[dummy@example.com (leethal)]]></author>
			<pubDate>Sat, 22 Sep 2007 15:08:40 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=39912#p39912</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cached files not being 'seen' after changing page_cache_directory]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=39906#p39906</link>
			<description><![CDATA[<p>I did a quick write up about this here <a href="http://www.bitbutter.com/page_cache_directory-gotcha/27">http://www.bitbutter.com/page_cache_directory-gotcha/27</a></p>]]></description>
			<author><![CDATA[dummy@example.com (cbit)]]></author>
			<pubDate>Sat, 22 Sep 2007 14:01:12 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=39906#p39906</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cached files not being 'seen' after changing page_cache_directory]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=38915#p38915</link>
			<description><![CDATA[<p>I&#039;ve specifically enabled caching for dev mode at the moment so i can see what&#039;s going on more clearly in the logs. Thanks for all the info, and for railscasts, that&#039;s turning out to be an excellent resource! If i figure out how to configure mongrel i&#039;ll post back here.</p>]]></description>
			<author><![CDATA[dummy@example.com (cbit)]]></author>
			<pubDate>Thu, 13 Sep 2007 17:58:33 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=38915#p38915</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cached files not being 'seen' after changing page_cache_directory]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=38899#p38899</link>
			<description><![CDATA[<p>Yeah, it looks like that will work. <a href="http://www.railsenvy.com/2007/2/28/rails-caching-tutorial">This tutorial</a> shows how to do it in lighttpd as well. As far as mongrel though, I&#039;m not sure how. Caching isn&#039;t normally enabled in development mode anyway, so is it an issue?</p>]]></description>
			<author><![CDATA[dummy@example.com (ryanb)]]></author>
			<pubDate>Thu, 13 Sep 2007 17:26:49 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=38899#p38899</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cached files not being 'seen' after changing page_cache_directory]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=38881#p38881</link>
			<description><![CDATA[<p>Hi ryan. Yes its page caching i&#039;m using, thanks for the clarification.</p><p>On my production server Apache is used as the front end. Am i correct in thinking that the following code (in .htaccess) is sufficient for the custom cache directory setup to work properly in that environment?:<pre name="code" class="ruby:nogutter">RewriteRule ^$ cache/index.html [QSA]<br />RewriteRule ^([^.]+)$ cache/$1.html [QSA]</pre><br />If so then i guess its just my local mongrel configuration that needs changing then so that caching works when i run the site on my development machine too.</p>]]></description>
			<author><![CDATA[dummy@example.com (cbit)]]></author>
			<pubDate>Thu, 13 Sep 2007 15:35:45 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=38881#p38881</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cached files not being 'seen' after changing page_cache_directory]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=38878#p38878</link>
			<description><![CDATA[<p>What kind of caching are you doing? Is it page caching? In that case Rails is never supposed to &quot;see&quot; the cache. It&#039;s supposed to be fetched directly by the web server (such as apache). So you&#039;ll need to configure your web server to look in that directory for the files.</p>]]></description>
			<author><![CDATA[dummy@example.com (ryanb)]]></author>
			<pubDate>Thu, 13 Sep 2007 15:23:00 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=38878#p38878</guid>
		</item>
		<item>
			<title><![CDATA[Re: Cached files not being 'seen' after changing page_cache_directory]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=38863#p38863</link>
			<description><![CDATA[<p>I have this same problem. Caching works in default mode but once I switch the directory, Rails kind of bugs out on me and doesnt even see the cache.</p><p>Any advice would be appreciated</p>]]></description>
			<author><![CDATA[dummy@example.com (pimpmaster)]]></author>
			<pubDate>Thu, 13 Sep 2007 13:51:18 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=38863#p38863</guid>
		</item>
		<item>
			<title><![CDATA[Cached files not being 'seen' after changing page_cache_directory]]></title>
			<link>http://railsforum.com/viewtopic.php?pid=38859#p38859</link>
			<description><![CDATA[<p>My question is: how can i get rails to use cached files when they are being created in the &#039;public/cache&#039; directory rather than in &#039;public&#039;?</p><p>Following the directions in fngtips article entitled &#039;lazy sweeping&#039; i changed the directory into which rails writes its cache files by adding the following line to my environment file.<br /><pre name="code" class="ruby:nogutter">config.action_controller.page_cache_directory = RAILS_ROOT+&quot;/public/cache/&quot;</pre><br />Running my app (locally) i can see that rails is creating the cache files properly in public/cache, but it&#039;s not &#039;seeing&#039; them. The next time the same url is accessed the log files show that the cache is being ignored, and getting re-generated.</p><p>If i remove the custom cache_directory instruction (so that cached files are dumped into the root of &#039;public&#039;) then rails uses the cached files as expected. But this is inconvenient for mass-deletion of cache files.</p><p>Does anyone know how to ensure that cached files stored in public/cache are used properly?</p>]]></description>
			<author><![CDATA[dummy@example.com (cbit)]]></author>
			<pubDate>Thu, 13 Sep 2007 13:20:17 +0000</pubDate>
			<guid>http://railsforum.com/viewtopic.php?pid=38859#p38859</guid>
		</item>
	</channel>
</rss>
