Forum Moderators: phranque

Message Too Old, No Replies

mod cache doesn't cache the homepage but the rest is cached. Solution?

         

enalgures

11:31 pm on Mar 23, 2009 (gmt 0)

10+ Year Member



Hello,

As many of you may know mod_cache does not cache directory index
files, this can be fixed with mod_rewrite but the index page of the domain (the homepage) seems to be impossible to cache it. The following rules cache the folders but not the homedir (this means that www.thedomain.com/folder is cached but www.thedomain.com is not):
DirectorySlash Off
RewriteEngine On
RewriteCond %{REQUEST_URI} ([^\.*])
RewriteCond "%{DOCUMENT_ROOT}%{REQUEST_URI}/index.htm" -f
RewriteRule "^(.*)$" "$1\/index.htm" [NC,L]
RewriteCond %{REQUEST_URI} ^([^\.*])$
RewriteCond "%{DOCUMENT_ROOT}%{REQUEST_URI}/index.html" -f
RewriteRule "^(.*)$" "$1\/index.html" [NC,L]
RewriteCond %{REQUEST_URI} ^([^\.*])$
RewriteCond "%{DOCUMENT_ROOT}%{REQUEST_URI}/index.php" -f
RewriteRule "^(.*)$" "$1\/index.php" [NC,L]

Note that DirectorySlash should be off (or mod_dir not loaded) in
order to work also with URL that end with no slash

As I said before this will work for any folder but it does not work for public homedir
directory. So when a user visit [thedomain.com...] it does not
work (unless you type the name of the index file: [thedomain.com...]

For me it is critical to make this work in someway, the index homepage
is the main page that needs to be cached in my case (and in many
others).

Do you know any solution for this? I found the first message about
this in the Internet in 2002 but I'm using last version of apache
httpd and still does not work.

If you have no idea about how to fix it, maybe you know some other easy alternative. Lighttpd + mod_cache + mod_deflate are not compatible: "mod_cache can be used in conjunction with other lighttpd plugins (except mod_deflate and mod_secdownload)"

Thank you in advance for your support.

g1smd

11:56 pm on Mar 23, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I can see why the index page wouldn't be cached - any change to any other page in that folder would need to be reflected in the index listing. However I know no way to override that; perhaps jd does?

enalgures

2:15 am on Mar 24, 2009 (gmt 0)

10+ Year Member



I'm not talking about the index listing of the files inside the folder, I'm talking about the homepage file (index.html, index.php, home.htm...). It is only cached if you go to www.thedomain.com/index.htm but not if you type only www.thedomain.com

I was thinking that maybe I can fix this by using Squid or Varnish instead of mod_cache. I know Squid can be installed in the same server than the webserver (by using apache in a different port than 80) so I guess it could do the same work than mod_cache. Anyone knows if this is possible or does anyone has another better recommendation?