-
Notifications
You must be signed in to change notification settings - Fork 70
Home
Jakub Tesinsky edited this page Jan 4, 2019
·
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 cached_pages/
:
config/production.rb:
config.action_controller.page_cache_directory = Rails.root.join "public/cached_pages"
RewriteEngine On
#Index Page
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{DOCUMENT_ROOT}/cached_pages/index.html -f
RewriteRule ^/$ /cached_pages/index.html [QSA]
# Other Pages
RewriteCond %{THE_REQUEST} ^(GET|HEAD)
RewriteCond %{REQUEST_URI} ^([^.]+)/?$
RewriteCond %{DOCUMENT_ROOT}/cached_pages/%1.html -f
RewriteRule ^([^.]+)$ /cached_pages/$1.html [QSA]
# Index HTML Files
if (-f $document_root/cached_pages/$uri/index.html) {
rewrite (.*) /cached_pages/$1/index.html break;
}
# Other HTML Files
if (-f $document_root/cached_pages/$uri.html) {
rewrite (.*) /cached_pages/$1.html break;
}
# All
if (-f $document_root/cached_pages/$uri) {
rewrite (.*) /cached_pages/$1 break;
}