The following instructions assume you have the latest version of the Proxy Cache Purge (formerly called “Varnish HTTP Purge”) plugin. If your WP-Admin shows that an update is available for this plugin, please update before proceeding or if you encounter difficulties with any of the following steps.
Overview
Your DreamPress site is automatically set up with the Proxy Cache Purge plugin. Without the plugin, your site may experience issues on DreamPress, such as the inability to save changes or display stale content to your visitors.
If you migrate a site from another host or upload from your local computer to DreamPress, you might overwrite this plugin with your plugin files.
If the plugin is removed, you can set it up again in the WordPress dashboard.
Installing and activating the Proxy Cache Purge plugin
- Go to your WordPress Admin Dashboard.
- Hover over the Plugins menu on the right and click on Add New.
- Type 'Proxy Cache Purge' in the 'Search Plugins' box in the upper right.
- Locate the Proxy Cache Purge plugin and click the Install button.
If you see an Activate button instead of an Install button, skip to step 5. If you see a greyed-out 'Active' button instead, skip to step 6.
- Click the Activate button.
- Refresh the page and click the 'Proxy Cache' menu on the left menu bar.
- Check that the "Set Custom IP" field at the bottom of the page shows 'localhost.' If it does not, change the field to read 'localhost,' then click the Save IP button to save it.
On Legacy DreamPress machines, this field should be the IP address of the DreamPress server.
Testing your site's cache performance using the Proxy Cache Purge plugin
Due to the thousands of plugins and customizations available for WordPress sites, not all sites automatically work effectively with all caching methods. The Proxy Cache Purge plugin offers an option in your WP-Admin panel to check page URLs on your site to ensure they are caching successfully. If a page on your site is not caching, the 'Check Caching' option tells you the items you can check that may resolve this issue.
To access this option:
- Open the WP-Admin page for your DreamPress site (e.g., example.com/wp-admin).
- Hover over 'Proxy Cache' and select the 'Check Caching' option.
- The 'Check Caching Status' page opens where you can check a URL on your site.
- Enter a URL in the 'Check A URL On Your Site' field box, then click the Check URL button.
This feature auto-scans the URL you selected and reports back any issues it finds, as well as any known problematic plugins. If the report says Your caching service appears to be running properly, that means caching on the server is working properly. However, if you see the Varnish caching service running but cannot cache your site, that means there is an issue with the server cache.
Testing your site's cache via SSH
If you can't use the Proxy Cache Purge plugin, you can also use an SSH command to check your site's cache.
[server]$ curl –I example.com
Your terminal will print several lines of information about the domain specified. If you see x-cache: hit and x-cacheable: Yes:Forced, the server proxy cache works as intended. If the proxy cache is not working, the command will return x-cache: Miss instead.
Troubleshooting DreamPress cache issues
If the Proxy Cache Purge plugin reports that your caching isn't working, there are several things you can test. The most common steps to resolve cache issues are toggling your plugins, switching out your theme, or identifying possible coding issues.
Proxy services like Cloudflare can cause false positives with the Proxy Cache Purge testing feature. DreamHost recommends temporarily pausing any proxy services if you're troubleshooting issues with your server caching.
Additionally, please note that the steps below require technical familiarity with your DreamPress site. If you need any assistance with the troubleshooting process, please contact support.
Switching to a default theme
The first and simplest thing to test is your site's theme. Change your site's active theme to a default theme (such as twentytwentyone) and check the site's server caching again. If you do not have any default themes installed, you can simply download and activate them within the wp-admin page.
Disabling your plugins
After you have verified that the site's theme is not responsible for the caching issues, you should test your plugins next. If any plugins known to cause issues with the server cache are installed on your site, you will see them identified in Proxy Plugin Cache's report output. Otherwise, use the steps below to test your site's active plugins.
DreamHost recommends backing up your site's database before making any changes.
Disable all plugins except for Proxy Cache Purge. Then, rerun the plugin's caching test to determine whether server caching is working.
If disabling plugins results in your site's caching service working again, that means there is a plugin that is the most likely cause of the cache issues. However, if you disabled multiple plugins, you must do further testing to determine which plugins may be responsible. Follow the instructions below to test the site's plugins individually.
- Enable your installed plugins one at a time, rerunning the cache test after each. Ensure you clear your site's cache after each test to avoid seeing cached results.
- Continue this process until the cache test returns the "unable to cache site" message, identifying the problematic plugin. Leave this plugin disabled.
- Reenable any remaining disabled plugins and run the test again. Multiple plugins may be responsible if the cache test continues to report issues. Continue the troubleshooting process until any plugins preventing the site's server cache are disabled.
If any disabled plugins are necessary for your site's intended functionality, you must contact their plugin developer to find a workaround or a way to work with the site's cache.
If your site uses any additional caching plugins, delete the contents of your ./wp-content/cache folder.
Checking your plugins and themes using SSH
If you are comfortable using SSH, you can run a pair of commands from your website directory to help narrow down the list of plugins and themes to check.
Run the following command to check your plugins for potentially problematic code:
[server]$ grep -Rilon -P '(?:PHPSESSID|session_start|start_session)' ./wp-content/plugins/
Run this command to check your theme's code:
[server]$ grep -Rilon -P '(?:PHPSESSID|session_start|start_session)' ./wp-content/themes/
Multiple false positives may exist, such as the Proxy Cache Purge plugin. Test any other plugins or themes that turn up in the results using the instructions in the previous sections of this article.
Testing your .htaccess
If your server caching is still not working even with your plugins disabled and the theme set to a default theme, your next step is to disable your site's .htaccess file. Using FTP or SSH, rename your .htaccess file to .htaccess.off and create a new .htaccess file with the default WordPress coding.
Some plugins may automatically add problematic lines to your site's .htaccess file. Below are two SSH commands that you can run to check for code that may conflict with the server cache:
[server]$ grep -r no-cache wp-content/* [server]$ grep -r age=0 wp-content/*
Once you've set up the default .htaccess, test your site's cache again. If the default .htaccess coding still doesn't fix your caching error, it's most likely the custom code used on your domain. Please be sure to check with your developer regarding any custom content.
Temporarily bypassing the DreamPress cache
The Proxy Cache Purge plugin includes a 'Development Mode' feature, allowing you to bypass caching for all visitors temporarily. This prevents visitors from seeing any old cached content on your WordPress site. You might find this useful if your site is still under development or if you are making major changes to the design. In addition, if you are having issues with a theme or plugin, your developer may ask you to try disabling the cache for further testing.
Your site runs slower when Development Mode is enabled, so please use it cautiously.
You can enable this feature for 24 hours, after which it automatically disables itself. You can also manually turn off Development Mode before the 24 hours have elapsed when you complete your changes or testing. Disabling Development Mode then allows DreamPress to resume caching and thus improves the page loading time for your visitors.
To disable caching (activate Development Mode):
- Open the WP-Admin dashboard page for your DreamPress site (e.g., example.com/wp-admin).
- Select 'Proxy Cache > Settings' in the left pane of your WP-Admin dashboard:
- The Proxy Cache Purge Settings page opens.
- Scroll down to the Development Mode Settings section and check the Activate Development Mode checkbox.
- Click the Save Settings button.
- A confirmation message appears on the settings page.
- You can also confirm if the built-in server cache is inactive by viewing the Cache status located in the WP-Admin toolbar at the top:
Development Mode remains active for 24 hours, after which it disables, and caching resumes normally. You can also manually disable Development Mode on this same page by returning to the 'Settings' page, unchecking the Development Mode checkbox, and then saving it.
Manually purging the cache via the plugin
The Proxy Cache Purge plugin includes a 'Purge Cache' button located in the WP-Admin toolbar at the top.
Clicking 'Purge Cache (All Pages)' purges the entire cache. USE SPARINGLY—the whole point of caching is to cache.
A better alternative is to selectively purge the cache of a specific item you changed when the changes aren’t showing up. You can purge a post or page from the cache using the plugin’s Purge Cache button when you view the live page.
To purge cache for an individual post or page:
- Make sure you are logged into WP-Admin for your site.
- Load the URL of the page or post you want to purge from the cache. You can also click the View link under the title of a post or page in WP-Admin to open the URL.
- In the WP-Admin toolbar at the top of the page, hover over the Cache button and select Purge Cache (This Page) from the dropdown menu options.
The page reloads, and the post or page is purged from the cache.
If you need to selectively purge specific files, such as CSS you manually changed and uploaded via SFTP/SSH, you'll need to do it via SSH for now.
Manually purging the cache via SSH
To manually purge the DreamPress cache, you must verify that the DreamPress user is a shell account, and make use of the WP-CLI command-line tool while logged into your domain via SSH.
The following is an example command of how to purge a single CSS file:
[server]$ wp varnish purge https://example.com/wp-content/themes/mytheme/style.css
If you are making changes to your theme files or updating various themes, the following is a simple way to clear all theme files from your cache:
[server]$ wp varnish purge https://example.com/wp-content/themes/ --wildcard