-
-
Save lukapaunovic/8bb9240d999a1e933fd2d6bb6995d9fd to your computer and use it in GitHub Desktop.
# Disable Woocommerce cart fragments for homepage via .htaccess | |
# By creating empty response | |
# Please replace yoursite.com | |
# Disable only on homepage | |
RewriteEngine On | |
RewriteCond %{HTTP_REFERER} ^https://yoursite.com/$ [NC] | |
RewriteCond %{QUERY_STRING} ^wc-ajax=get_refreshed_fragments$ | |
RewriteRule ^(.*)$ $1 [R=204,L] | |
# Disable everywhere | |
RewriteEngine On | |
RewriteCond %{QUERY_STRING} ^wc-ajax=get_refreshed_fragments$ | |
RewriteRule ^(.*)$ $1 [R=204,L] |
for me works on Apache 2.4 with nginx Proxy
Works, thanks on Apache 2!
@guikare
doesnt work!
It doesn't work with some configurations, so here's an alternative that does.
It requires creating a blank 404.php file from which we'll get a blank response
# BEGIN Disable cart fragments
RewriteEngine On
# Uncomment rule bellow and update with your site url if you want to disable only for homepage
#RewriteCond %{HTTP_REFERER} ^https://yoursite.com/$ [NC]
RewriteCond %{QUERY_STRING} ^wc-ajax=get_refreshed_fragments$
RewriteRule ^(.*)$ /404.php [NC,L]
# END Disable cart fragments
Didn't work for me (tried disabling everywhere) but the alternative seems better for me. It does cause a 500 error based on the waterfall but at least it's quick vs. the 1s+ the call was taking before. Thanks!
As for that internal error, it makes me believe something's not right since it should be finding the 404.php file I created, no??? Any ideas on how to fix that? Sometimes, it's taking >500ms to return the 500 error...
@jayeq, if you are using the method which uses 404.php file then you need to create that file, of course.
The content of the 404.php file should be:
<?php
http_response_code(204);
die();
Then in waterfall u should see 204 response instead of 500 error.
I used your settings all the time and it was great!
It doesn't work anymore. Could give new instructions ..?
My site
WooCommerce 3.8.1
WordPress 5.3
PHP 7.4
MySQL 5.7.16-10-log
doesnt work!