No, cookies will not break caching. They are used only to save enabled debugging functons.
Of course, while using debugging functions you should disable caching.
Thanks, Igor! This is the cookie that my host said was being generated:
$ curl -I (my site URL removed)
HTTP/1.1 200 OK
Server: openresty/1.11.2.1
Date: Sun, 02 Oct 2016 18:56:53 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive
Keep-Alive: timeout=30
Link: <(my site URL removed)>; rel=”https://api.w.org/”
Set-Cookie: AI_WP_DEBUGGING=0; expires=Sun, 02-Oct-2016 19:56:53 GMT; Max-Age=3600; path=/
Set-Cookie: AI_WP_DEBUG_BLOCK=0; expires=Sun, 02-Oct-2016 19:56:53 GMT; Max-Age=3600; path=/
Vary: Accept-Encoding, User-Agent
X-User-Agent: standard
X-Cache-Config: 0 1
X-Cache-Status: BYPASS
Does this look normal, and all is ok? I don’t have any debugging functions enabled that I know of.
It looks normal 🙂
Debugging functions are disabled and in next version in such case cookie will not be generated.
Thanks for your help, I appreciate it. 🙂
Hi Igor,
I wanted to check and see when you’re planning on releasing the next version of this plugin with the cookies not being generated?
Thanks so much for your help!
Adina
Please try development version:
https://downloads.wordpress.org/plugin/ad-inserter.zip
Cookie is now created only when debugging is enabled.
Hi Igor,
Thanks for releasing the newest version! Is there a way to disable cookies entirely in this version of the plugin?
The latest version does not use cookies unless you enable debugging functons. And when you enable debugging it uses cookie only for the logged in admin user.
Hi Igor,
I’ve spent a couple of time working on checking things to allow cache on pagely using your plugin in a client website.
As you stated you’re removing the cookies when !is_admin(), this is correct, but pagely still detects the header cookies and disables caching on the website.
The way to solve this would be to remove_action() the debugging functions from ‘wp’ when debug mode is off.
I’ve managed to make this work creating a small plugin to remove your hook. But I think it would be good to have this in your code when debug is off.
Thanks
Thanks for suggestion.
I’ll try to include this in the next release.
Hi,
Can you please be more specific – which hook causes issues with cookies?
Hi igor, sure.
Here’s the code of my simple plugin that solves the issue:
remove_action( 'wp', 'ai_wp_hook' );
function foundry_ai_wp_hook () {
global $ai_wp_data, $ai_db_options_extract;
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("WP HOOK START");
set_page_type ();
set_user ();
if ($ai_wp_data [AI_WP_PAGE_TYPE] != AI_PT_ADMIN && ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0 && get_admin_toolbar_debugging ())
add_action ('admin_bar_menu', 'ai_toolbar', 20);
$url_debugging = get_remote_debugging () || ($ai_wp_data [AI_WP_USER] & AI_USER_ADMINISTRATOR) != 0;
if (!is_admin()) {
if (isset ($_GET [AI_URL_DEBUG]) && $_GET [AI_URL_DEBUG] == 0) {
unset ($_COOKIE ['AI_WP_DEBUGGING']);
setcookie ('AI_WP_DEBUGGING', '', time() - (15 * 60), COOKIEPATH);
unset ($_COOKIE ['AI_WP_DEBUG_BLOCK']);
setcookie ('AI_WP_DEBUG_BLOCK', '', time() - (15 * 60), COOKIEPATH);
} else {
$ai_wp_data [AI_WP_DEBUGGING] = isset ($_COOKIE ['AI_WP_DEBUGGING']) ? $ai_wp_data [AI_WP_DEBUGGING] | ($_COOKIE ['AI_WP_DEBUGGING'] & ~AI_DEBUG_PROCESSING) : $ai_wp_data [AI_WP_DEBUGGING];
$ai_wp_data [AI_WP_DEBUG_BLOCK] = isset ($_COOKIE ['AI_WP_DEBUG_BLOCK']) ? $_COOKIE ['AI_WP_DEBUG_BLOCK'] : 0;
if (isset ($_GET [AI_URL_DEBUG_BLOCKS]))
if ($_GET [AI_URL_DEBUG_BLOCKS] && $url_debugging) $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_BLOCKS; else $ai_wp_data [AI_WP_DEBUGGING] &= ~AI_DEBUG_BLOCKS;
if (isset ($_GET [AI_URL_DEBUG_TAGS]))
if ($_GET [AI_URL_DEBUG_TAGS] && $url_debugging) $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_TAGS; else $ai_wp_data [AI_WP_DEBUGGING] &= ~AI_DEBUG_TAGS;
if (isset ($_GET [AI_URL_DEBUG_NO_INSERTION]))
if ($_GET [AI_URL_DEBUG_NO_INSERTION] && $url_debugging) $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_NO_INSERTION; else $ai_wp_data [AI_WP_DEBUGGING] &= ~AI_DEBUG_NO_INSERTION;
if (isset ($_GET [AI_URL_DEBUG_POSITIONS])) {
if ($_GET [AI_URL_DEBUG_POSITIONS] !== '' && $url_debugging) $ai_wp_data [AI_WP_DEBUGGING] |= AI_DEBUG_POSITIONS; else $ai_wp_data [AI_WP_DEBUGGING] &= ~AI_DEBUG_POSITIONS;
if (is_numeric ($_GET [AI_URL_DEBUG_POSITIONS])) $ai_wp_data [AI_WP_DEBUG_BLOCK] = intval ($_GET [AI_URL_DEBUG_POSITIONS]);
if ($ai_wp_data [AI_WP_DEBUG_BLOCK] < 0 || $ai_wp_data [AI_WP_DEBUG_BLOCK] > AD_INSERTER_BLOCKS) $ai_wp_data [AI_WP_DEBUG_BLOCK] = 0;
}
if ($ai_wp_data [AI_WP_DEBUGGING] != 0)
setcookie ('AI_WP_DEBUGGING', $ai_wp_data [AI_WP_DEBUGGING], time() + AI_COOKIE_TIME, COOKIEPATH);
if ($ai_wp_data [AI_WP_DEBUG_BLOCK] != 0)
setcookie ('AI_WP_DEBUG_BLOCK', $ai_wp_data [AI_WP_DEBUG_BLOCK], time() + AI_COOKIE_TIME, COOKIEPATH);
}
}
$debug_positions = ($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_POSITIONS) != 0;
$debug_tags_positions = ($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_POSITIONS | AI_DEBUG_TAGS)) != 0;
$debug_tags_positions_blocks = ($ai_wp_data [AI_WP_DEBUGGING] & (AI_DEBUG_POSITIONS | AI_DEBUG_TAGS | AI_DEBUG_BLOCKS)) != 0;
$plugin_priority = get_plugin_priority ();
if (isset ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [CONTENT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_tags_positions)
add_filter ('the_content', 'ai_content_hook', $plugin_priority);
if (isset ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [EXCERPT_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_tags_positions_blocks)
add_filter ('the_excerpt', 'ai_excerpt_hook', $plugin_priority);
if (isset ($ai_db_options_extract [LOOP_START_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [LOOP_START_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions)
add_action ('loop_start', 'ai_loop_start_hook');
if (isset ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) && count ($ai_db_options_extract [LOOP_END_HOOK_BLOCKS][$ai_wp_data [AI_WP_PAGE_TYPE]]) != 0 || $debug_positions)
add_action ('loop_end', 'ai_loop_end_hook');
if (($ai_wp_data [AI_WP_DEBUGGING] & AI_DEBUG_PROCESSING) != 0) ai_log ("WP HOOK END\n");
};
add_action( 'wp', 'foundry_ai_wp_hook' );