Rails Caching

Discussion in 'Ruby/Rails' started by jp_n9, Oct 14, 2006.

  1. jp_n9

    jp_n9 New Member

    I setup Rails Caching using the caches_page method. I can see the files being created in /public, yet according to the production.log Rails is still processing every file.

    Any ideas??? Do I need to setup a directive in the VirtualHost for the Rails app, or could it be arouting problem, or something else?

    Thanks!!
  2. mistwang

    mistwang LiteSpeed Staff

    Not sure what cause that, the URL must be exactly as the the file name, index file should be set properly.

    You can turn on debug logging see what exactly is happening.
  3. jp_n9

    jp_n9 New Member

    An example URL is http://www.domain.com/view/page/17

    On my server I have

    /domain/current/public/view/page/17.html

    Now, I noticed in the VirtualHost that under the "Rewrite" tab, "Enable rewrite" is off by default. Do I need to turn that on for LS to be able to turn .../page/17 into .../page/17.html??

    Any other settings that "should" be right but might be a good idea for me to double check?

    Thanks for all your help!!

    I'll send you a copy via PM of the error.log with the highest level of debugging for a request.
    Last edited: Oct 15, 2006
  4. mistwang

    mistwang LiteSpeed Staff

    Yes, you need to rewrite the url. :)
  5. jp_n9

    jp_n9 New Member

    I tried turning it on, but it doesn't seem to have changed anything. Ooops. Just saw you said the URL needs to be rewritten. How?
  6. mistwang

    mistwang LiteSpeed Staff

    You can just turn on .htaccess support, the rewrite rules in public/.htaccess should take care of it.
  7. jp_n9

    jp_n9 New Member

    I found the "Allow Override" setting, but it has a bunch of check boxes which aren't explained - so I'm not sure how to "turn on" the .htaccess support. I tried checking all except for the "none" and restarted. Didn't seem to work.

    I then adding the following rewrite rules copied from .htacess:

    RewriteRule ^$ index.html [QSA]
    RewriteRule ^([^.]+)$ $1.html [QSA]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteRule ^(.*)$ dispatch.cgi [QSA,L]

    I restarted. Again, it still doesn't seem to be working.

    What am I doing wrong?
  8. mistwang

    mistwang LiteSpeed Staff

    rewrite rules in .htaccess are slightly different from rules at vhost level. The rewrite base (directory path) has been removed for rewrite rules in .htaccess. You need to modify those rewrite rules to take care of this.

    try something like

    RewriteRule ^(.*)/$ $1/index.html [QSA]
    RewriteRule ^([^.]+)$ $1.html [QSA]


    Or, you can turn off htaccess and use those rules in the rails context configuration, but not at the vhost level.
  9. jp_n9

    jp_n9 New Member

    I turned off .htaccess and added the above rewrite rules in at the vhost level. Works great!! Thanks!

Share This Page