Cache

Developer documentation for the Ajax Load More Cache add-on.


Auto-Generate Cache

The Ajax Load More cache can be auto-generated by populating the alm_cache_array filter with an array of cache URLs and IDs.

The alm_cache_array filter let’s Ajax Load More know which cache instances should be auto-generated when the build is initiated.

Parameters

The following array parameters are available for each cache item –  url and id are required fields for each.

url The URL to the page holding the cache instance.Required
id The unique cache_id of the ALM instance.Required
max The maximum number of cache pages to create per item.

Before the cache is auto-generated, the current Ajax Load More cache is emptied – this means even cache instances that are not set to be auto-generated will be cleared.

Note: The Ajax Load More cache is not built on it’s own, it requires you to initiate the build process from the WordPress admin.

Building the Cache

To start the cache build process, you’ll need to visit the Ajax Load More Cache page in your WordPress admin and click the Generate Cache button in the sidebar.

Auto-generate Ajax Load More Cache admin screen

Once initiated, you will be redirected to a new page (as shown above) where you can track the cache progress and status.

Note: If you exit the page while auto-generating the cache, the process will stop where you exited.


Filter Hooks

The following filter hooks are available when using this add-on:

 alm_cache_created

The alm_cache_created action is triggered after a cache file has been created.

alm_cache_deleted

The alm_cache_deleted action is triggered after an individual cache file or the entire ALM cache has been deleted.

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.

NOTE: When filtering the cache location you must update both alm_cache_path and alm_cache_url hooks.

alm_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.

NOTE: When filtering the cache URL you must update both alm_cache_path and alm_cache_url hooks.


alm_clear_cache

The alm_clear_cache action can be used by authenticated user roles to clear the entire Ajax Load More cache.


« Back to Add-ons