Created
March 22, 2011 14:58
-
-
Save schowdhury/881346 to your computer and use it in GitHub Desktop.
rails caching with apache enable through rewrite rules
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I generate all my page caching in public/cache directory. The following apache rewrite rules check cache before hitting the rails app | |
<VirtualHost *:80> | |
RewriteEngine On | |
RewriteCond %{THE_REQUEST} ^(GET|HEAD) | |
RewriteCond %{REQUEST_URI} ^/([^.]+)$ | |
RewriteCond %{DOCUMENT_ROOT}/cache/%1.html -f | |
RewriteRule ^/[^.]+$ /cache/%1.html [QSA,L] | |
RewriteCond %{THE_REQUEST} ^(GET|HEAD) | |
RewriteCond %{DOCUMENT_ROOT}/cache/index.html -f | |
RewriteRule ^/$ /cache/index.html [QSA,L] | |
ServerName myserver.com | |
DocumentRoot /var/www/rails/myproject/current/public | |
PassengerEnabled off | |
ProxyPass / http://127.0.0.1:8080/ | |
ProxyPassReverse / http://127.0.0.1:8080/ | |
</VirtualHost> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment