Home >Web Front-end >JS Tutorial >How to Prevent Browser Caching for AJAX Results in jQuery?
When loading dynamic content via AJAX using jQuery's $.get(), you may encounter browser caching, leading to outdated data being displayed.
To resolve this, adding a random query string parameter, such as the current timestamp, has been commonly used. However, there is a more elegant approach.
By adding the following code snippet, you can globally disable AJAX result caching regardless of the jQuery method used:
$.ajaxSetup({ cache: false });
This setting effectively instructs the browser not to cache future AJAX requests, ensuring that you always retrieve the latest content.
The above is the detailed content of How to Prevent Browser Caching for AJAX Results in jQuery?. For more information, please follow other related articles on the PHP Chinese website!