Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if( defined('DOING_AJAX') && DOING_AJAX && strcasecmp($_SERVER['REQUEST_METHOD'], "POST") == 0 && !empty($_POST['action']) && $_POST['action'] == "{your_action}") {
- $ajax_cache_path = WP_CONTENT_DIR . "/custom-cache/{$_SERVER['HTTP_HOST']}/cache_ajax/";
- $cache_key = ajax_cache_key(); //Generates a unique filename with sha1 based on information from the POST request (GET information is always the same in this case)
- if( file_exists($ajax_cache_path . $cache_key) ) {
- header('content-type: application/json; charset=UTF-8');
- header('AJAX-Cache: HIT');
- die( file_get_contents($ajax_cache_path . $cache_key));
- }
- ob_start( 'ajax_cache_end' );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement