AO and Woocommerce
-
Hello, I was wondering if it is safe to use AO with Woocommerce and also, since the Woocommerce pages aren’t cached, if this would lead to long page loading of the shop pages since AO relies on page caching in order to be fast.
-
there are multiple sites using WC + AO, but some configuration might be needed (multiple threads on this subject here in the autoptimize support forum).
from what I see, page caching in general is done for all WC-pages except cart & checkout and AO can be configured not to be active on those pages (using the API, autoptimize_filter_noptimize, cfr. the example in autoptimize_helper.php_example)
hope this clarifies,
frankThank you for your fast reply. I activated the helper.php, but I am not sure how and where to add the relevant urls now?
there is only one block of relevant code;
add_filter('autoptimize_filter_noptimize','my_ao_noptimize',10,0); function my_ao_noptimize() { if (strpos($_SERVER['REQUEST_URI'],'no-autoptimize-now')!==false) { return true; } else { return false; } }
in there the 3rd line will contains (part) of the URL and could become;
(alert: untested code!)if ((strpos($_SERVER['REQUEST_URI'],'cart')!==false)||(strpos($_SERVER['REQUEST_URI'],'checkout')!==false) {
hope this helps,
frankYeah, this did not work at all, site went blank…
as I wrote, untested code, you might have to tinker with that block of code (or ask a developer for help).
frank
OK, tested and there was a closing bracket missing. this at least will not cause your blank screen;
if ((strpos($_SERVER['REQUEST_URI'],'cart')!==false)||(strpos($_SERVER['REQUEST_URI'],'checkout')!==false)) {
frank
Thank you so much for having a look at it again. I guess the code still needs to be changed since it is still aggregating. I saw in the Woocoomerce docs that they tell you to exclude mfunc from minifying if you use W3. Since I am using AO for minifying, could this be a solution? I have no idea what mfunc is or does…
well, the code assumes the cart-page has “cart” in the path of the URL and the checkout has “checkout”, if that is not the case you would have to adjust those.
I saw in the Woocoomerce docs that they tell you to exclude mfunc from minifying if you use W3.
you could try adding that to the comma-separated JS-optimization exclusion list, yes. no idea what it does though π
have fun,
frankHi Frank,
unfortunately I still haven’t been able to figure out how to exclude the Woocommerce pages from AO. I read somewhere to use is_cart and is_checkout instead of uri, but I am not sure how to implement this in your function?
Thank you so much,
daninain that case the function would be something like this (beware, untested code coming up);
add_filter('autoptimize_filter_noptimize','woo_noptimize',10,0); function woo_noptimize() { if ( ( is_cart() ) || ( is_checkout() ) ) { return true; } else { return false; } }
frank
Just getting back to you, this code works π Thank you very much. I am just wondering if I should also include my single product pages in the code since they are not cached either…I only have 5 products so I could include them via is_page(…) but I am not sure if I could even leave AO on for these pages even if they are not cached.
Just out of curiosity: i know BWP Minify has a cache busting option that you can also customize, I am not sure if this plugin works completely different but how come cache busting is possible with the other?
great to hear this works!
regarding cache busting; you can empty the cache from the admin-page, there just is no automatic purging (to avoid pages becoming broken).
frank
Hey Frank, yes I know I can empty the cache manually, it just takes VERY long to get the cache up again and it is a pain to go through every single page and post to make sure they are cached…
it just takes VERY long to get the cache up again and it is a pain to go through every single page and post to make sure they are cached…
there’s a plugin for that π
frank
Yes, but I don’t have a sitemap and really don’t want to install plugin over plugin… wish there was a way w/o plugin…
- The topic ‘AO and Woocommerce’ is closed to new replies.