# Search Cache

Ajax Search Pro features a super fast File and Database cache, as well as an automated image cropping feature to optimize server traffic.

{% embed url="<https://youtu.be/fUHvavCjz_M>" %}

### Enable Search Cache

By default the search cache is disabled. To turn it on, navigate to the **Cache** submenu under the Ajax Search Pro sidebar menu and go to the **Settings** tab.

<figure><img src="https://1706764988-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L9jkFgNo4lpUof35gvS%2Fuploads%2FYJ7Y5d5M9s4nVPGlYg5M%2Fimage.png?alt=media&#x26;token=a9b362c3-1826-4406-9277-0740a761a87e" alt=""><figcaption></figcaption></figure>

### Cache Settings Explained

#### Results cache method

This determines how the caching is realized.

* **Super file** (default) - Recommended method. Uses *.json* files in the WordPress cache folder to store the data. It is the fastest, because the files are directly requested through the user client, without making a back-end request to the WordPress.
* **File** - Similar to the Super File, but the files are requested through WordPress instead of the client directly.
* **Database** - The cache is stored in the database instead of the files.

#### Purge the results cache when a post is created/updated?

When enabled the cache is completely emptied whenever a post (or any custom post type) is inserted, deleted or modified.

{% hint style="warning" %}
If you expect frequent changes on your posts but still want to use a cache, then this option should be turned off to avoid constant cache purges. Otherwise it makes caching obsolete.
{% endhint %}

#### Cache images by cropping them

When enabled the plugin will process images in the live results list and resize them to the preferred dimensions and sizes for better loading and image quality.

{% hint style="info" %}
Highly recommended when using image preview in results. While initial queries will be slower because of image generation, in repeated requests it pays off in both traffic reduction and overall response time.
{% endhint %}

### Cache Statistics

The cache statistics is integrated with the [Search Statistics](https://documentation.ajaxsearchpro.com/search-statistics) feature. To record cache stats, make sure the [search statistics is also enabled](https://documentation.ajaxsearchpro.com/search-statistics#enable-search-statistics).

The cache statistics displays a 24 hour and all time cache hit/miss ratio as well as a list of the past 20 cache hits.

<figure><img src="https://1706764988-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L9jkFgNo4lpUof35gvS%2Fuploads%2F8QQuUwO53pwaRofysmpz%2Fimage.png?alt=media&#x26;token=fa7efb2d-2dc1-44cf-a8da-bc31527dff06" alt="" width="375"><figcaption></figcaption></figure>

If you want to see more details, then navigate to the **Search Statistics** submenu, where you can use the Cache Status filter on All Searches for more details statistics.

<figure><img src="https://1706764988-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-L9jkFgNo4lpUof35gvS%2Fuploads%2FlHaPEEZJGfgaZAr3zgN9%2Fimage.png?alt=media&#x26;token=02a71ece-8c38-4ea6-82c6-48ac73b0eec4" alt="" width="375"><figcaption></figcaption></figure>
