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.

Examination of cache headers

Many frameworks change headers and set policies that are convenient for the developer, rather than tuned for performance or the production environment. Hence, you should check and know 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 (our servers default to 10 minutes), by setting the «Expires» header one week into the future. This means that both our front-end server and your web browser is told not to re-request this file before it expires.

Such behaviour can cause trouble while developing, because the css file does not refresh, although the file is changed. 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.

Control Panel Settings
There are three cache settings in the control panel that control the behaviour of the front-end web server (nginx).

Front-end cache: Off

When caching is 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 when developing.

When «developer mode» is enabled, this setting is automatically set to Off.

Front-end cache: Static (default)

Caching of static elements is the default behaviour. In this mode elements like images, javascript and style sheets are cached for a short period of time. This 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

Front-end cache: All

This setting also allows caching for HTML and PHP output. For PHP applications this will require that headers are properly set. For Magento 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.
Was this article helpful?
Thank you!