Solidus' resource cache is great to speed up pages for general users, but seriously slows down testing and publishing new content. This pull request introduces a new "no-cache mode" to fix this problem. The mode is enabled when the first subdomain of the host is preview (by default, configurable with the no_cache_subdomain option). This means a production site can be hosted and browsed normally on domain.com or abc.domain.com, and its no-cache version will be accessible through preview.domain.com or preview.abc.domain.com. This pull request makes Solidus follow the no-cache request headers, which are sent when a user forces-refresh a page in his browser.
When the Cache-Control: no-cache request is detected, the following changes happen to the request:
The Cache-Control: no-cache and Pragma: no-cache request HTTP headers are added to all resources. This enables the end-to-end reload of the resources from the proxies and APIs.
The resources cache is skipped, in order to get fresh data from the APIs. The resources cache is still updated with the fresh data, so normal requests can benefit from it.
The response HTTP headers are set to disable the caching and indexation of the response: Cache-Control: no-cache, no-store, max-age=0, must-revalidate and X-Robots-Tag: noindex, nofollow.
Fixes #133
Solidus' resource cache is great to speed up pages for general users, but seriously slows down testing and publishing new content.
This pull request introduces a new "no-cache mode" to fix this problem. The mode is enabled when the first subdomain of the host isThis pull request makes Solidus follow thepreview
(by default, configurable with theno_cache_subdomain
option). This means a production site can be hosted and browsed normally ondomain.com
orabc.domain.com
, and its no-cache version will be accessible throughpreview.domain.com
orpreview.abc.domain.com
.no-cache
request headers, which are sent when a user forces-refresh a page in his browser.When the
Cache-Control: no-cache
request is detected, the following changes happen to the request:Cache-Control: no-cache
andPragma: no-cache
request HTTP headers are added to all resources. This enables the end-to-end reload of the resources from the proxies and APIs.The response HTTP headers are set to disable the caching and indexation of the response:Cache-Control: no-cache, no-store, max-age=0, must-revalidate
andX-Robots-Tag: noindex, nofollow
.