The Cache add-on creates static HTML files of Ajax Load More requests then delivers those static files to your visitors without querying the database.
Caching will improve the user experience of your site by boosting server performance and dramatically reducing content load times for your visitors.
How It Works
The Cache add-on takes the results of each initial Ajax Load More query and creates static HTML files within the /ajax-load-more-cache/_cache directory.
The static HTML files are then referenced and served to your visitors without making additional ajax requests to your WordPress database.
The cache is created on the fly the first time a user visits a page and loads Ajax Load More content. During the cache creation process it will be invisible to the user that they are creating the new cache content.
The next user who visits that same page will be served the cached static HTML and Ajax Load More will not make any database requests until the cache is cleared.
During the process of creating the individual cache files a 404 error may appear in the developer console of your browser, this does not affect the rendering of the page but is a necessary occurrence while Ajax Load More creates the static HTML files.
To enable caching you must activate the Cache add-on with each ajax_load_more shortcode – this will give you complete control over what content is cached across on your site.
|cache||Turn on content caching for this Ajax Load More query (true/false). Default = ‘false’|
|cache_id||A unique 10 digit ID for the cached query (true/false). Default = ‘false’|
Simply set cache to true, generate a unique 10 digit cache_id using our random ID generator and caching will be enabled for this specific Ajax Load More instance.
While it is possible to modify the unique cache_id, it may result in undesired results and we highly recommend caching using the ID value assigned by the random generator.
Example Shortcode[ajax_load_more cache="true" cache_id="3478900362" posts_per_page="4" pause="true" scroll="false"]
Try it for yourself! Click the Load Posts from Cache button below and notice the speed at which the posts are loaded.
The Ajax Load More Cache dashboard has been designed and developed to give you a transparent overview of your current cache.
You can delete the entire cache or choose to delete individual directories – you can also search for cached URLs or IDs and view statistics on the amount of files and directories currently in the cache.
Within each of the directory listings you will find a link to the Cached URL, the date and time the cache was created and the complete list of static HTML files created by Ajax Load More Cache.
By default, the Cache add-on will write and serve all cached files from your WordPress uploads directory (/wp-content/uploads/alm-cache/).
As of version 1.5 users are able to adjust the location of the ALM cache by using the following filter hooks.
The alm_cache_path filter can be used to update the absolute server path of the Ajax Load More Cache – this path is used when writing and saving files to your server.
The following snippet will adjust the default cache path to a /cache/ folder in the current theme directory.
// Add to functions.php
return get_stylesheet_directory() .'/cache/';
The alm_cache_url filter can be used to update the URL path to the Ajax Load More Cache – this URL is used when rendering the cached content of an Ajax Load More query.
The following snippet will adjust the default cache URL to a /cache/ folder in the current theme directory.
// Add to functions.php
return get_stylesheet_directory_uri() .'/cache/';
NOTE: When filtering the cache location you must update both alm_cache_path and alm_cache_url hooks.
The Ajax Load More cache can be set to auto-generate by populating the alm_cache_array filter in the backend of your site. Auto-generating the cache benefits both developers and end users as it provides the ability for admins to build out a complete cache of the Ajax requests before users visit the website.
During the build process, admins are able to track the progress and status of each cache instance directly on the Ajax Load More Cache dashboard – more info the docs.
The Cache add-on has global settings (available on the main Ajax Load More settings screen) that can help automate the cache process.
Published Posts – Checking this box will flush the Ajax Load More cache every time a page, post or custom post type is published or updated. This will ensure your visitors are always seeing the latest content.
Known Users – Checking this box will turn off caching for all logged in users – from subscribers all the way up to site administrators.
Upon purchase of this add-on you will receive a confirmation/purchase receipt email. Your receipt will contain a direct link for downloading your copy of Ajax Load More: Cache and a license key.
After downloading the add-on, upload the unzipped files to your /wp-content/plugins/ directory or visit your plugins dashboard and upload the downloaded .zip under Add New.
To activate your add-on and receive updates directly in your WordPress plugins dashboard users are required to enter the license key that was included with their purchase receipt.
To activate a license key:
- Visit the Licenses section within the Ajax Load More plugin.
- Enter the product key and click Activate License.
- If the status indicator turns green your add-on has been successfully activated (example below).
If you did not receive your confirmation/purchase receipt email and license key, please check your spam/junk folder and if you still cannot locate the email please contact me at darren [at] connekthq.com or use the Product Support form on the website.