-
Notifications
You must be signed in to change notification settings - Fork 70
Home
Xavier Noria edited this page Sep 23, 2018
·
4 revisions
Use these sample configurations as a starting place to configure Apache or Nginx to serve the static pages generated by this gem.
These examples assume a cache directory configured to use a directory called page_cache/
:
config/production.rb:
config.action_controller.page_cache_directory = Rails.root.join "public/page_cache"
RewriteEngine On
#Index Page
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}/page_cache/index.html -f
RewriteRule ^/$ /page_cache/index.html [QSA]
# Other Pages
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{REQUEST_URI} ^([^.]+)/?$
RewriteCond %{DOCUMENT_ROOT}/page_cache/%1.html -f
RewriteRule ^([^.]+)$ /page_cache/$1.html [QSA]
# Index HTML Files
if (-f $document_root/page_cache/$uri/index.html) {
rewrite (.*) /page_cache/$1/index.html break;
}
# Other HTML Files
if (-f $document_root/page_cache/$uri.html) {
rewrite (.*) /page_cache/$1.html break;
}
# All
if (-f $document_root/page_cache/$uri) {
rewrite (.*) /page_cache/$1 break;
}