Last Updated: 28th Feb 2017
Donncha: Coming up in WP Super Cache 1.5.0
The next version of WP Super Cache will be one with some big changes! There are many small bug fixes and improvements but the one Iâ€™m most excited about is moving the legacy cache files into the supercache directory.
The legacy cache files were the files created by the old WP-Cache plugin upon which this plugin is based. Theyâ€™re really useful as they store the headers sent from the server as well as the page contents. If youâ€™re serving pages that arenâ€™t regular html, such as JSON or XML you donâ€™t want to tell the browser theyâ€™re text/html documents. This caching method is also used for anyone who is logged into your site, or left a comment.
There is a problem however. Theyâ€™re stored in one directory. If you have many thousands of visitors interacting with your site you may end up with a directory containing thousands of files. The names of the cache files are a hash of the URL, gzip support and browser cookies so one file can match one user, or one file can be used by thousands of anonymous users. In the event that someone left a comment on a popular post the plugin has to search through all those files looking for the pages cached for other users who were also looking at that page. On a busy server that can cause problems.
So, in #177 I added code that moves the legacy cache files into the supercache directory. That means the files are stored in directories that reflect the URL of the page that was served which makes it very easy to delete the cached files belonging to that page as theyâ€™re all in the same directory!
The new code will look in the old location for legacy files first as some sites will have a large collection of cached files, but any new cache files will be created in the supercache directory.
Ian Dunn submitted code to cache the REST API. Itâ€™s not yet complete but weâ€™ll be able to build on the changes to the legacy cache to make caching the API more efficient than it would have been before.
I really need people to help test this. The latest code is running on this site so Iâ€™m very confident in how well it works but just because it works on my odd little server doesnâ€™t mean it will work right everywhere. If you want to give it a spin, visit the plugin Github repository and click on the â€śClone or downloadâ€ť button. If you donâ€™t know how to clone a Git respository just grab the zip file and install it on your server, overwriting the files in the plugins/wp-super-cache/ directory. If the changes to where cache files go doesnâ€™t interest you, some of the changes in this list might:
- Donâ€™t output broken warning in robots.txt
- Use get_home_url() instead of siteurl because some sites have different homepages
- Remove most calls to get_all_supercache_filenames()
- Fix bottom border in admin
- Use plugins_url() so https links work
- Preload from the newest post
- Stop caching of wp-admin visits sooner
- Store legacy cache files in the supercache directories
- Make the headers more informative to tell how a page was served
- Properly serve 304 requests
- Apply realpath to filenames because of Windows oddities
- Donâ€™t flush(), output buffers donâ€™t like it
- Add more file checks around wp_cache_rebuild_or_delete()
- If HTTP_HOST is not defined then disable caching
- Only show html comments on html pages
- Fix caching of mobile requests
- Clear the cache for private posts