The setup of all sites on our servers involves two web servers. A front-end webserver (nginx) that handles SSL connections, load balancing and caching, and a back-end web server (Apache) that handles PageSpeed and runs your PHP application.
The front-end web server (nginx) obeys the cache policies that are defined in the headers delivered by Apache. This means that your web application, or overrides of default policies in the
.htaccess file will affect the behavior of the front-end cache.
Servebolt’s caching solution is designed to be a general purpose high performance cache, needing zero maintenance.
Examination of cache headers
Many frameworks change headers and set policies that are convenient for the developer instead of having those tuned for performance inside a production environment. This is why it’s important to check how your application behaves. This can be done by checking the headers of elements using your browser.
In the following example we are examining a CSS file generated by Magento. Magento overrides our server default settings of 10 minutes by setting the «Expires» header one week into the future. This means that both our front-end server and your web browser are told not to re-request this file before it expires.
This behaviour can cause trouble while developing, because the CSS file does not refresh even though you as a developer have changed the file. To get past this there are several options, but the simplest is to add a new and unique parameter to the file. For instance, a reference in HTML to
styles.css could be rewritten to
styles.css?v=1 . When the non-cached HTML changes, this element will be treated as new both by our front-end webserver and the browser and will thus always display the latest version number.
Servebolt Control Panel Settings
Each site on your Bolt has a settings page in the Servebolt Control Panel. There are three different cache settings available. They control the behaviour of the front-end web server (nginx).
When caching is turned off off, nginx passes all requests back to the back end webserver (Apache), which delivers the requested file directly from the file system. This is resource intensive, and makes web pages load much slower. Therefore this setting should only be used while developing the site.
When developer mode is enabled, caching is also automatically set to Off. Which means that additionally PageSpeed is also disabled while in developer mode.
Cache: Static Files (default setting)
The Servebolt standard setup is tuned for good performance and a fairly high level of convenience for the developer. Caching of static elements reduces the load on the back-end webserver, and speeds up loading of web pages.
The period of time an element is cached for varies on a http response code basis:
- 200 (OK) 30 minutes
- 301 (Redirect) 5 minutes
- 404 (Page not Found) 1 minute
Static files get a 7 day expiry header, which means that the elements are cached for up to 7 days in nginx and the user’s browser.
Cache: Static Files + Full-Page Cache
This setting also allows caching for HTML and PHP output. For PHP applications this will require that headers are properly set.
For Magento 2 and WooCommerce we maintain plugins that can be installed on your website, and that alter the default behaviour of these applications to work according to standards. You can find them here: