Cache
Improve website performance by caching the results of Ajax server requests
The Cache add-on creates static files of Ajax Load More requests and delivers those static files without directly querying the WordPress database.
Caching can improve the user experience of your site by boosting server performance and drastically reducing content load times for your visitors.
Features
A few key features of the Cache add-on for Ajax Load More.
Boost Performance
Reduce stress and load on your server by minimizing database queries and serving static cached files.
Auto-Generation
The Ajax Load More cache can be auto-generated on the server by using the alm_cache_array filter.
Administration
Take control of your cached content with our intuitive cache management and administration dashboard.
Improved Load Times
Reducing page load times has been proven to increase your visitors time on site and overall number page views.
Add-on Details
Learn more about the Cache add-on.
How It Works
The Cache add-on takes the results of each initial Ajax Load More query and saves the responses as a static file in the WordPress uploads directory.
The static files are then served to your visitors without the need to make additional ajax requests to your WordPress database.
Cache Creation
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 cached content.
The next user who visits that same page will be served the static cached content and Ajax Load More will not query the database again until the cache is cleared.
Shortcode Parameters
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 your site.
cache | Enable the Ajax Load More cache for this query. (true/false). |
---|---|
cache_id | A unique ID for the cached query. |
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.
Shortcode Builder
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.
Cache Management
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 files created by Ajax Load More Cache.
Cache Location
By default, the Cache add-on will write and serve all cached files from your WordPress uploads directory (/wp-content/uploads/alm-cache/).
This directory can be adjusted by using the following hooks.
Filter Hooks
alm_cache_path
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.
// functions.php
add_filter('alm_cache_path', function() {
return get_stylesheet_directory() . '/cache/';
});
PHPalm_cache_url
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.
// functions.php
add_filter('alm_cache_url', function() {
return get_stylesheet_directory_uri() . '/cache/';
});
PHPNOTE: When filtering the cache location you must update both alm_cache_path and alm_cache_url hooks.
Auto-Generation
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 can track the progress and status of each cache instance directly on the Ajax Load More Cache dashboard – More Info.
Cache Settings
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.
Installation
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.
License Activation
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 a confirmation email containing your license key, please check your spam/junk folder. If you still cannot locate the email, contact me at darren [at] connekthq.com or use the Product Support form.