• Resolved sasserp01

    (@sasserp01)


    Hello,

    Always like to start off by saying love the plugin. I’ve got a site running WordPress and Autoptimize. The site uses WooCommerce and products are filtered by two store locations. The site uses session variables to set the location. If the session var is one location or another the main query is adjusted to include that location. Is there anyway to account for this using autoptimize? So essentially this URL product-category/arm-chair/ might show three different things 1) All the products in that category, 2) all the products in that category at location 1, and 3) all the products in that category at location 2.

    Thanks much for the help and support.

Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Author Frank Goossens

    (@futtta)

    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

    Thread Starter sasserp01

    (@sasserp01)

    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

    Plugin Author Frank Goossens

    (@futtta)

    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?

    Thread Starter sasserp01

    (@sasserp01)

    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

    Thread Starter sasserp01

    (@sasserp01)

    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 8 years, 1 month ago by sasserp01.
    Plugin Author Frank Goossens

    (@futtta)

    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?

    Thread Starter sasserp01

    (@sasserp01)

    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.

    Plugin Author Frank Goossens

    (@futtta)

    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?

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Autoptimize and Session Variables’ is closed to new replies.