How rails check and fetch Page Cache file?

After posting this question
page cache more than 100K files inside a single directory?
http://www.ruby-forum.com/topic/108450#new
I’ve been look into how page caching works.

Now I’ve rewritten page_cache_file(path) (Module
ActionController::Caching::Pages::ClassMethods). now it will divide
page_cache files into subdirectories to avoid more than 10K files to be
stored inside a single directory. (788.html-> 0/788.html; 79780.html->
7/9780.html).

But since the default save path being changed, rails generate the
content from database ignoring the cached files.
so, I need to let rails know that cache files’ location are changed

Digging for hours, I couldn’t get any idea on how rails check and fetch
page cache files.

Can anyone give me a clue?

On 5/18/07, Nanyang Z. [email protected] wrote:

7/9780.html).

But since the default save path being changed, rails generate the
content from database ignoring the cached files.
so, I need to let rails know that cache files’ location are changed

Digging for hours, I couldn’t get any idea on how rails check and fetch
page cache files.

Can anyone give me a clue?

It doesn’t. Your web server’s rewrite routes need to be written in a
way that it checks for the existence of a file and serves it before
even bothering rails. This is static-heavy sites like the main Rails
site and weblog are blazing fast. Apache’s doing the heavy lifting.


Rick O.
http://lighthouseapp.com
http://weblog.techno-weenie.net
http://mephistoblog.com

On 5/18/07, Nanyang Z. [email protected] wrote:

still knew the cache files. It let me believe that the job was done
inside the rails…
so I was wrong…

Mongrel does the same thing too. When in doubt, watch your logs for
rails requests.

Now I’ll try to use apache’s httpd.conf file. It surely can redirect to
cache file.
Before that, I need to learn complex rewrite rule for mod_rewrite…
If you’ve done this before, can you give me a quick help?
I need a apache mod_rewrite rule to rewrite
/data/98 to /data/0/98.html
and
/data/89798 to /data/8/9798.html
(/data/:id, ids are divided into two parts, four digitals for file name,
left will be dir name.)

Why not just use the partitioned IDs in the rails routes themselves?


Rick O.
http://lighthouseapp.com
http://weblog.techno-weenie.net
http://mephistoblog.com

Rick O. wrote:

Why not just use the partitioned IDs in the rails routes themselves?

sorry, I don’t understand.

You mean rails know partitioned ids?
or you suggest instead of calling /data/89798, but using /data/8/9798 to
fetch the data?

I think apache rewrite is perfect to do this rewrite job. Faster at
least.

Rick O. wrote:

Your web server’s rewrite routes need to be written in a
way that it checks for the existence of a file and serves it before
even bothering rails.

I’d tried to remove
RewriteRule ^([^.]+)$ $1.html [QSA]
from public/.htaccess, but mongrel(development env, without apache)
still knew the cache files. It let me believe that the job was done
inside the rails…
so I was wrong…

Now I’ll try to use apache’s httpd.conf file. It surely can redirect to
cache file.
Before that, I need to learn complex rewrite rule for mod_rewrite…
If you’ve done this before, can you give me a quick help?
I need a apache mod_rewrite rule to rewrite
/data/98 to /data/0/98.html
and
/data/89798 to /data/8/9798.html
(/data/:id, ids are divided into two parts, four digitals for file name,
left will be dir name.)

finally, I come up with these rewrite rule:
RewriteRule ^([^.]+)/(\d{1,4})$ /$1/0/$2.html [QSA]
RewriteRule ^([^.]+)/(\d+)(\d{4,})$ /$1/$2/$3.html [QSA]

will them work?

I need a apache mod_rewrite rule to rewrite
/data/98 to /data/0/98.html
and
/data/89798 to /data/8/9798.html
(/data/:id, ids are divided into two parts, four digitals for file name,
left will be dir name.)

or you suggest instead of calling /data/89798, but using /data/8/9798 to
fetch the data?

Yup.

I think apache rewrite is perfect to do this rewrite job. Faster at
least.

Ok.


Rick O.
http://lighthouseapp.com
http://weblog.techno-weenie.net
http://mephistoblog.com

Rick O. wrote:

using /data/8/9798 to fetch the data?

Yup.

BTW,
this url is ugly and misleading. I won’t use it.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs