Forum Moderators: phranque
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.
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?