Back to Community

How to Fix the admin-ajax.php Caching Issue in LiteSpeed Cache

15 threads Oct 1, 2025 PluginLitespeed cache

Content

A common issue that arises when using the LiteSpeed Cache plugin alongside dynamic plugins, such as WPML or e-commerce currency switchers, is the caching of the admin-ajax.php file. This can break functionality that relies on real-time, non-cached AJAX requests. This guide will explain why this happens and how to resolve it.

Why Does This Happen?

The admin-ajax.php file is a core WordPress file used to handle AJAX requests. These requests are dynamic by nature and often involve user-specific data, such as shopping cart contents or currency selections. When a caching plugin like LiteSpeed Cache serves a cached version of this file, it returns the same response to every user, breaking the intended dynamic behavior. As seen in user reports, support teams for other plugins will often identify this as the root cause when their functionality fails only when LiteSpeed Cache is active.

How to Exclude admin-ajax.php from Caching

The solution is to instruct LiteSpeed Cache not to cache the admin-ajax.php file. This is done by adding an exclusion rule within the plugin's settings.

  1. Navigate to the Cache Settings: In your WordPress admin dashboard, go to LiteSpeed Cache > Cache > Advanced.
  2. Find the Exclusion Settings: Look for the setting labeled "Do Not Cache URIs".
  3. Add the Exclusion: In the input field, add the following line:
    /wp-admin/admin-ajax.php
  4. Save Changes: Scroll down and click "Save Changes" to apply the new rule.

After saving, it's crucial to purge all existing cache to ensure the new rule takes effect immediately. You can do this from the LiteSpeed Cache > Toolbox > Purge menu by selecting "Purge All".

Testing the Fix

Once you have added the exclusion and purged the cache, test the functionality that was previously broken. For example, if you were troubleshooting a WPML currency switcher, try switching currencies on a product page. The action should now work correctly without displaying outdated or incorrect information.

Additional Considerations

If the problem persists after this change, consider the following:

  • Query Strings: Some AJAX requests use unique query strings. You may need to investigate if additional exclusions are needed in the "Do Not Cache Query Strings" setting.
  • Server-Level Caching: If you are on a LiteSpeed server, there might be server-level page caching rules at play. In such cases, you may need to consult your hosting provider to ensure the exclusion is applied at the server level as well.

By excluding admin-ajax.php from the cache, you allow dynamic, user-specific requests to function as intended while still benefiting from LiteSpeed Cache's performance optimizations on the rest of your site.

Related Support Threads Support