fbpx
Want To Add Extra Images Per Product Variation For Free? Download Now

Woo Variations inadvertently enables WP-Admin caching in LiteSpeed Cache

Lisa Clarke

Hello.

I am having a problem with my WP-Admin Product, Post, Page, and Media pages being cached by LiteSpeed Cache, even though LiteSpeed does not cache WP-Admin.

I found the following lines of code, which turn DONOTCACHEPAGE false. LiteSpeed uses the DONOTCACHEPAGE constant to indicate that WP-Admin pages should not be cached. By changing the value to false, you are overriding that behavior, and effectively marking WP-Admin pages as cacheable. For now, I have added wp-admin to the Do Not Cache URLs section as a work-around, but hopefully this is something you can fix in a future update. Thanks!

./wp-content/plugins/woo-variation-swatches/includes/class-woo-variation-swatches-product-page.php:84:                    wc_maybe_define_constant( 'DONOTCACHEPAGE', false );
./wp-content/plugins/woo-variation-swatches-pro/includes/class-woo-variation-swatches-pro-rest-api.php:45:                add_filter( 'litespeed_const_DONOTCACHEPAGE', '__return_false' );


Lisa Clarke

I have some additional information from the LiteSpeed development team:

The first one is inside of an if condition.
if ( $action && in_array( $action, $requests ) ) {
Try updating it to this:
if ( wp_doing_ajax() && $action && in_array( $action, $requests ) ) { 

Not sure if it will work, but the overall problem that he is trying to resolve is to try to cache ajax requests. This will not happen normally because ajax requests are always in wp-admin, so he is trying to circumvent this

I hope this helps.

Hakik Zaman

Hi Lisa,

Thanks for reaching out to us. I have sent your suggestions and issue to our development team.

They are working on it and I will get back to you once I get an update from them.

Thanks in advance for your patience.

Lisa Clarke

Thanks for looking into it. Also, I work for LiteSpeed, and I can put your development team in touch with our development team, if necessary to help with compatibility 🙂

Hakik Zaman

Hi Lisa,

Thanks for your co-operation. We have removed DONOTCACHEPAGE in our latest release.

Will you please check and confirm if everything is working well or not?

Thank You

Lisa Clarke

It looks good to me. Thank you for taking care of this quickly!

Lisa

Hakik Zaman

Hi Lisa,

Your cooperation is much appreciated.

Please let us know if you face any issues in near future.

Again thanks for contacting us.

Thank You