How do I configure StackCache?
StackCache comes free for all WordPress sites on our WordPress Managed Hosting and Reseller WordPress Hosting platforms. StackCache has a number of options that can be used to personalise your caching, depending on what your site needs.
This includes altering the cache expiry for different file types, additional options for how caching should be handled and when purging should occur, and the means to exclude pages from StackCache’s caching.
How do I access the StackCache settings?
In order to access the settings for StackCache, you'll need to sign in to the wp-admin area of your site.
Once there, from the dashboard you will see StackCache listed as one of the options in the sidebar - select this, and you'll be greeted with the main page for StackCache. From here you can begin making changes as you need.
The settings within StackCache are broken down into four sections:
- Cache Expiry Settings
- StackCache Configuration
- Advanced Settings
- Cache Exclusion
Cache Expiry Settings
The first section focuses on managing your site's cache expiry settings for different types of files - these settings determine how long a file type is stored for in cache before a fresh version is requested, and can be set for the following:
- Dynamic Cache: StackCache is primarily responsible for the caching of dynamic content on your site, such as scripts, comments and forms. This value handles how long they're stored for in seconds. By default, the value is set to 3600, which is 1 hour in seconds. Below the box, you'll see various preset values that will auto-fill the corresponding number of seconds for that time, or you can enter your own value.
- Image Cache: This value sets how long your different types of image are stored for, including types like PNG, JPEG, WEBP and SVG. The default value is 1 day.
- HTML/CSS Cache: This value handles how long the HTML content of your site is stored. The default value is 1 day.
- JavaScript Cache: This defines how long the JavaScript for your site is stored for. The default value is 1 day.
These change the expiry dates of files that match the file type – the modifications are saved and stored in the .htaccess file in the root of your site folder. They’ll be saved in a format such as this:
#+StackCache
#={"images":"A86400","css":"A86400","javascript":"A86400"}
ExpiresActive ON
ExpiresByType "image/jpeg" "A86400"
ExpiresByType "image/jpg" "A86400"
ExpiresByType "image/gif" "A86400"
ExpiresByType "image/png" "A86400"
ExpiresByType "image/svg+xml" "A86400"
ExpiresByType "image/webp" "A86400"
ExpiresByType "image/vnd.microsoft.icon" "A86400"
ExpiresByType "image/x-icon" "A86400"
ExpiresByType "image/ico" "A86400"
ExpiresByType "font/ttf" "A86400"
ExpiresByType "font/otf" "A86400"
ExpiresByType "application/x-font-opentype" "A86400"
ExpiresByType "application/x-font-woff" "A86400"
ExpiresByType "application/x-font-ttf" "A86400"
ExpiresByType "application/font-woff" "A86400"
ExpiresByType "font/woff2" "A86400"
ExpiresByType "application/vnd.ms-fontobject" "A86400"
ExpiresByType "text/css" "A86400"
ExpiresByType "text/javascript" "A86400"
ExpiresByType "application/javascript" "A86400"
#-StackCache
StackCache Configuration
Further changes can be made to the behaviour of WordPress and StackCache using the settings available in this section.
- Automatic WordPress Updates: This adds a rule to wp-config that disables WordPress core updates – useful for if you wish to keep your WP version to a specific one for security or compatibility. This is enabled by default.
- Hide Purge Cache Link: The header bar at the top of wp-admin has an area that states Purge Cache and allows for you to purge the cache from anywhere in wp-admin. This option hides that link if it’s not needed. It’s disabled by default.
- Allow Editors to control StackCache: By default, StackCache is only accessible by wp-admin users with Administrator level access. This option changes it to allow Editor roles access as well, in case these need to clear the cache to show new updates. This is disabled by default.
- Disable StackCache: This temporarily disables the StackCache plugin entirely for debugging purposes. By default, this is enabled.
Advanced Options
The Advanced Options area allows for more specific cache-related modifications to be made to StackCache.
These settings can cause issues with the caching if implemented poorly, and so we recommend only enabling these on advice of either a developer or our support team.
These options are as follows:
- Remove PHP Session Cookies From All Pages: Prevent PHP Sessions from being started by your website. This will allow cache to function if PHP Session cookies are preventing it.
- Remove PHP Session Cookies Matching Empty PHP Sessions: This prevents any empty sessions being set by PHP cookies.
- Remove All Cookies From Your Homepage: Stops any cookies being set by your home page to help guarantee a cache hit. If you require cookies around your site but are looking for a quick loading home page, this can enable full page caching on your homepage whilst allowing cookies to be set on subpages.
- Make Automatic Cache Purging Purge Everything: When we detect content changes, we automatically purge the cache for the post/page URL modified, the index page and your sites RSS feed automatically. Enabling this option will trigger a full cache purge whenever these events are detected.
- Perform Automatic Cache Purging For All Post Types: By default, we only automatically purge the cache when standard post types are modified. Enabling this options will trigger a cache purge regardless of post type.
- Disable WordPress Built-in Theme / Plugin Editor: This is the equivalent of defining DISALLOW_FILE_EDIT in your wp-config.php file.
- Hide WordPress Version: Strip the meta generator tags from the page source and RSS feeds. This makes it harder for bots to identify the version of your WordPress site.
Cache Exclusions
The last page of settings allows for cache exclusions to be added to StackCache.
This informs StackCache to not cache that endpoint. Several examples are given of the formatting required for these rules. You can add multiple new rules using the Add Another Rule button if needed, which will create a new field for you to add an additional rule to.
Note: This only excludes the pages from StackCache caching. Origin and CDN cache can still cache these pages if implemented.