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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 5/18/07, Nanyang Zhan <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > 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?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 Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rick Olson 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.) -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 5/18/07, Nanyang Zhan <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Rick Olson 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...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 Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rick Olson 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. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> 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 Olson http://lighthouseapp.com http://weblog.techno-weenie.net http://mephistoblog.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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.)-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Rick Olson wrote:>> using /data/8/9798 to fetch the data? > > Yup.BTW, this url is ugly and misleading. I won''t use it. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---