Xavier Noria edited this page Sep 23, 2018 · 3 revisions

Web Server Configuration

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"

Apache

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]

NGINX

# 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;
}
Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.