Hi sasserp01; AO “simply” aggregates JS/ CSS it finds in any page. if for the same page it gets different CSS/ JS, it simply creates a new version of the autoptimized code and continues with that. So at first thought this seems like an issue for a page caching plugin rather then for AO? Or am I missing something here?
frank
Hey Frank,
Ahh okay. So Autoptimize …
1) gets the page request
2) aggregates JS/CSS on that page
3) compares that compressed version of the page with what is cached
4) If a cached copy is “equal” to the page comparison then the cached page is served
4b) Otherwise the newly compressed version is cached and served
Am I correct here? So Something else must be caching these session variables. WP Super Cache is out there, but I could have sworn that I disabled caching for these particular pages.
Thanks much,
patrick
almost; but in (3) AO compares the aggregated but not minified JS/ CSS with what is already in cache (based on an md5-hash) and in (4) the cached JS/CSS is served if the the cached file exists and in (4b) the file is saved as autoptimize_<md5hash-of-the-unminified-code>.js (or .css)
if not WPSC this is maybe some object cache?
What do you mean by object cache? This is blowing my mind right now. If I’m logged into WP-Admin then the session variables work. If I’m not logged into WP-Admin then the session variables don’t work. WP-SuperCache adds in a comment at the bottom of the source code that tells you the page is cached by WP-SuperCache and on the pages in question there is no comment. So They aren’t being cached by WP-SuperCache, unless there is some sort of residual cache (I’ve deleted cached like a million times). Any thoughts? I’ll keep digging
Thanks,
patrick
Ok I think I figured it out here is the code that I had going on…
add_action ('pre_get_posts', 'woo_destroy_session' );
function woo_destroy_session ($query) {
if(is_shop() || is_page( ) ) {
if ( is_session_started() === TRUE ) session_destroy();
}
}
The session would be destroyed essentially if you leave the shop page. So you set a location session to filter items by and then when you go to a page or back to the main shop page that session is removed. However, strangely when you are logged into WP-Admin this if works as expected
if(is_shop() || is_page( ) )
and then when you log out it doesn’t work anymore as expected and it always returns true so the session is always deleted. Any ideas as to why this might be happening? More of a general WordPress question.
Thanks,
patrick
-
This reply was modified 9 years, 6 months ago by
sasserp01.
The session would be destroyed essentially if you leave the shop page.
correct me if I’m wrong (I often am), but doesn’t this code destroy the session when you’re on a shop-page or a page and if a session exists?
You’re right. I sort of misspoke. The session is supposed to be destroyed if you’re on a page or if you’re on the main shop page. So if(is_shop() || is_page( ) ) should be what I’m looking for. Just not sure why it isn’t working.
hmmm .. out of my comfort zone here and not really an on-topic reply, but why destroy the session at all? If the session only affects the products shown by location, then you could just let that session live, even on non-shop pages where it would have no impact?