How to exclude cart from FastCGI caching?
-
Hello, I’m using FastCGI + Nginx Helper, the problem is caching /cart/ page, visitors cannot add/remove items from the cart, I have used the rules suggested in this answer but still facing the same issue even after purging all the cache. When purging the page manually (clicking
Purge Current Page
on the admin bar) the page work for one time then back to misbehaving and showing a cached page.The page I need help with: [log in to see the link]
-
Hi @icyb3r
I understand you are using the Nginx Helper plugin and that when you purge cache manually it works normally just once.
1. Can you please check if the solutions provided in this article work for you?
https://easyengine.io/wordpress-nginx/tutorials/plugins/woocommerce/2. There may also be some server side caching involved and you’d want to check if cookies are being set by the server. This thread provides some solutions to handle that: https://serverfault.com/questions/786097/handling-caching-with-nginx-when-cookies-are-being-set-by-the-server
I hope these lead to resolution of the issue. If the problem still persists please share a copy of your site’s System Status for us to take a closer look. You can find it via WooCommerce > Status. Select “Get system report” and then “Copy for support”. Once you’ve done that, paste it here in your response.
Hi @margaretwporg,
Thank you for the fast response, I have tried all of the above solutions but none of them worked for me.
Here’s full system report:
### WordPress Environment ### WordPress address (URL): https://shbkyat.com Site address (URL): https://shbkyat.com WC Version: 6.5.1 REST API Version: ? 6.5.1 WC Blocks Version: ? 7.4.3 Action Scheduler Version: ? 3.4.0 Log Directory Writable: ? WP Version: 5.9.3 WP Multisite: – WP Memory Limit: 256 MB WP Debug Mode: – WP Cron: ? Language: ar External object cache: – ### Server Environment ### Server Info: nginx/1.19.8 PHP Version: 7.4.27 PHP Post Max Size: 50 MB PHP Time Limit: 300 PHP Max Input Vars: 1000 cURL Version: 7.70.0 OpenSSL/1.0.2u SUHOSIN Installed: – MySQL Version: 5.5.5-10.1.47-MariaDB Max Upload Size: 50 MB Default Timezone is UTC: ? fsockopen/cURL: ? SoapClient: ? DOMDocument: ? GZip: ? Multibyte String: ? Remote Post: ? Remote Get: ? ### Database ### WC Database Version: 6.5.1 WC Database Prefix: wp_ Total Database Size: 27.60MB Database Data Size: 24.71MB Database Index Size: 2.89MB wp_woocommerce_sessions: Data: 0.08MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_api_keys: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_attribute_taxonomies: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_downloadable_product_permissions: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_woocommerce_order_items: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_order_itemmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_tax_rates: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_woocommerce_tax_rate_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_shipping_zones: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_woocommerce_shipping_zone_locations: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_shipping_zone_methods: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_woocommerce_payment_tokens: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_woocommerce_payment_tokenmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_woocommerce_log: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_actionscheduler_actions: Data: 0.30MB + Index: 0.45MB + Engine InnoDB wp_actionscheduler_claims: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_actionscheduler_groups: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_actionscheduler_logs: Data: 0.19MB + Index: 0.16MB + Engine InnoDB wp_berocket_termmeta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_commentmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_comments: Data: 0.02MB + Index: 0.09MB + Engine InnoDB wp_ewwwio_images: Data: 0.08MB + Index: 0.06MB + Engine InnoDB wp_ewwwio_queue: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_gs_logo_slider: Data: 0.06MB + Index: 0.00MB + Engine InnoDB wp_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_options: Data: 10.47MB + Index: 0.13MB + Engine InnoDB wp_oses_attachments: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_oses_clicks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_oses_emails: Data: 0.05MB + Index: 0.02MB + Engine InnoDB wp_oses_email_attachments: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_oses_failures: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_oses_jobs: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_postmeta: Data: 7.45MB + Index: 0.28MB + Engine InnoDB wp_posts: Data: 4.36MB + Index: 0.09MB + Engine InnoDB wp_rank_math_404_logs: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_rank_math_analytics_ga: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_rank_math_analytics_gsc: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_rank_math_analytics_inspections: Data: 0.02MB + Index: 0.11MB + Engine InnoDB wp_rank_math_analytics_keyword_manager: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_rank_math_analytics_objects: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_rank_math_internal_links: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_rank_math_internal_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_revslider_css: Data: 0.13MB + Index: 0.02MB + Engine InnoDB wp_revslider_css_bkp: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_revslider_layer_animations: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_revslider_layer_animations_bkp: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_revslider_navigations: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_revslider_navigations_bkp: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_revslider_sliders: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_revslider_sliders_bkp: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_revslider_slides: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_revslider_slides_bkp: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_revslider_static_slides: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_revslider_static_slides_bkp: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_snippets: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_tcb_api_error_log: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_td_fields: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_td_groups: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_termmeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_terms: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_term_relationships: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_term_taxonomy: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_usermeta: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_users: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_wc_admin_notes: Data: 0.06MB + Index: 0.00MB + Engine InnoDB wp_wc_admin_note_actions: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_category_lookup: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wc_customer_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_download_log: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_order_coupon_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_order_product_lookup: Data: 0.02MB + Index: 0.06MB + Engine InnoDB wp_wc_order_stats: Data: 0.02MB + Index: 0.05MB + Engine InnoDB wp_wc_order_tax_lookup: Data: 0.02MB + Index: 0.03MB + Engine InnoDB wp_wc_product_attributes_lookup: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_product_download_directories: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_product_meta_lookup: Data: 0.02MB + Index: 0.09MB + Engine InnoDB wp_wc_rate_limits: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_reserved_stock: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wc_tax_rate_classes: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wc_webhooks: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_wpforms_tasks_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wpmailsmtp_debug_events: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_wpmailsmtp_tasks_meta: Data: 0.02MB + Index: 0.00MB + Engine InnoDB wp_yith_wcwl: Data: 0.02MB + Index: 0.02MB + Engine InnoDB wp_yith_wcwl_lists: Data: 0.02MB + Index: 0.03MB + Engine InnoDB ### Post Type Counts ### attachment: 240 blc-product-review: 9 custom_css: 5 customize_changeset: 6 elementor_library: 7 et_pb_layout: 3 gp_elements: 9 gs-logo-slider: 40 nav_menu_item: 17 page: 13 post: 9 product: 5 product_variation: 4 revision: 47 shop_order: 8 sp_lc_shortcodes: 1 sp_logo_carousel: 40 tcb_content_template: 4 tcb_lightbox: 1 tvd_login_edit: 1 tve_notifications: 1 wp_block: 3 wp_global_styles: 1 wpcf7_contact_form: 1 wpforms: 1 ### Security ### Secure connection (HTTPS): ? Hide errors from visitors: ? ### Active Plugins (15) ### Contact Form 7: by Takayuki Miyoshi – 5.5.6 GenerateBlocks Pro: by Tom Usborne – 1.1.2 GenerateBlocks: by Tom Usborne – 1.4.2 GP Premium: by Tom Usborne – 2.1.2 Nginx Helper: by rtCamp – 2.2.2 Paylink: by Paylink Co – 1.05 Perfmatters: by forgemedia – 1.9.0 Rank Math SEO PRO: by Rank Math – 3.0.9 Rank Math SEO: by Rank Math – 1.0.85.1 Thrive Product Manager: by Thrive Themes – 1.3.0 Thrive Architect: by <a href="https://www.thrivethemes.com">Thrive Themes</a> – 3.9.1 Checkout Field Editor for WooCommerce: by ThemeHigh – 1.6.0 WooCommerce: by Automattic – 6.5.1 WP Crontrol: by John Blackbourn & crontributors – 1.12.1 WP Offload SES: by Delicious Brains – 1.5.6 ### Inactive Plugins (6) ### All-in-One WP Migration With Import: by ServMask – 6.77 CMP - Coming Soon & Maintenance Plugin: by NiteoThemes – 4.1.1 Code Snippets: by Code Snippets Pro – 3.0.1 Duplicate Page: by mndpsingh287 – 4.4.8 UpdraftPlus - Backup/Restore: by UpdraftPlus.Com DavidAnderson – 1.22.12 WP Force SSL: by WebFactory Ltd – 1.65 ### Dropin Plugins (1) ### advanced-cache.php: advanced-cache.php ### Settings ### API Enabled: – Force SSL: – Currency: SAR (?.?) Currency Position: right_space Thousand Separator: . Decimal Separator: , Number of Decimals: 2 Taxonomies: Product Types: external (external) grouped (grouped) simple (simple) variable (variable) Taxonomies: Product Visibility: exclude-from-catalog (exclude-from-catalog) exclude-from-search (exclude-from-search) featured (featured) outofstock (outofstock) rated-1 (rated-1) rated-2 (rated-2) rated-3 (rated-3) rated-4 (rated-4) rated-5 (rated-5) Connected to WooCommerce.com: – Enforce Approved Product Download Directories: – ### WC Pages ### Shop base: #7 - /services/ Cart: #8 - /cart/ Checkout: #9 - /checkout/ My account: #10 - /account/ Terms and conditions: ? Page not set ### Theme ### Name: GeneratePress Version: 3.1.3 Author URL: https://tomusborne.com Child Theme: ? – If you are modifying WooCommerce on a parent theme that you did not build personally we recommend using a child theme. See: How to create a child theme WooCommerce Support: ? ### Templates ### Overrides: – ### Action Scheduler ### Complete: 893 Oldest: 2022-04-21 15:25:05 +0000 Newest: 2022-05-18 14:10:28 +0000 Failed: 1 Oldest: – Newest: – Pending: 7 Oldest: 2022-05-19 14:10:28 +0000 Newest: 2022-05-20 16:00:04 +0000 ### Status report information ### Generated at: 2022-05-18 18:38:28 +03:00
- This reply was modified 2 years, 6 months ago by icyb3r.
@margaretwporg Any help?
Hi @icyb3r
Sorry for the delay – it looks like we weren’t notified of your reply.
I have tried all of the above solutions but none of them worked for me.
Thanks for sharing the System Status Report.
I see that there is a caching plugin active on your site.
### Dropin Plugins (1) ### advanced-cache.php: advanced-cache.php
Can you please contact your host and have them temporarily disable the plugin above to see if that fixes the issue?
Keep us posted on how it goes.
Thanks
Hi, @margaretwporg
advanced-cache.php Appears to be empty.
I have no hosting company I’m the server manager and owner, and the only plugin I have is Nginx helper plugin. And yes when disabling FastCGI everything goes back to normal, but I would like to keep the FastCGI and fix the cart issue, would that be possible?
Hi @icyb3r! Thanks for writing back!
Can you share the rules you added to remove the cart page from your caching system?
Also, would you mind sharing your NGINX errors log with us, if there are any? If you have enabled it, you can find them in
/var/log/nginx
I hope to hear from you soon! All the best,
Hello @chiape,
Thank you for your response, here’s what you requested.
Nginx Rules:
set $skip_cache 0; # POST requests and urls with a query string should always go to PHP if ($request_method = POST) { set $no_cache 1; } if ($request_method = PATCH) { set $no_cache 1; } if ($query_string != "") { set $no_cache 1; } # Don't cache uris containing the following segments if ($request_uri ~* "/ad/|/wp-admin/|/wp-login/|/xmlrpc.php|index.php|phpmyadmin|sitemap(_index)?.xml|sitemap$") { set $no_cache 1; } if ($request_uri ~* "(/ad/|/wp-admin/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { set $no_cache 1; } if ($request_uri ~* "(/ad/|/wp-admin/|/cart/|/checkout/|/account/|/mon-compte/|/xmlrpc.php|/wp-(app|cron|login|register|mail).php|wp-.*.php|/feed/|index.php|wp-comments-popup.php|wp-links-opml.php|wp-locations.php|sitemap(_index)?.xml|[a-z0-9_-]+-sitemap([0-9]+)?.xml)") { set $no_cache 1; } # Don't use the cache for logged in users or recent commenters if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in|postpass|wordpress_n$") { set $no_cache 1; } # Woocommerce if ($request_uri ~* "/cart/|/services.*|/store.*|/cart.*|/account.*|/my-account.*|/checkout.*|/addons.*|/panier.*|/paiement.*|/mon-compte.*") { set $no_cache 1; } if ( $arg_add-to-cart != "" ) { set $no_cache 1; } # need more tests #if ( $cookie_woocommerce_items_in_cart != "0" ) { # set $no_cache 1; #} if ( $cookie_woocommerce_items_in_cart ) { set $no_cache 1; } if ($request_method = POST) { set $skip_cache 1; } if ($query_string != "") { set $skip_cache 1; } if ($request_uri ~* "/ad/|/wp-admin/|/xmlrpc.php|wp-.*.php|/feed/|index.php|sitemap(_index)?.xml") { set $skip_cache 1; } if ($http_cookie ~* "comment_author|wordpress_[a-f0-9]+|wp-postpass|wordpress_no_cache|wordpress_logged_in") { set $skip_cache 1; }
Nginx error log:
2022/02/09 07:52:22 [crit] 20533#0: unlink() "/dev/shm/fastcgi-cache/d/ed/01fa6067e472269022c54e22b61ebedd" failed (2: No such file or directory) 2022/02/09 07:52:47 [crit] 20533#0: unlink() "/dev/shm/fastcgi-cache/7/15/afc3dcac95761652cafc07a391243157" failed (2: No such file or directory) 2022/02/09 07:54:00 [crit] 20533#0: unlink() "/dev/shm/fastcgi-cache/9/ff/22a613a63da249608fa71acdcd365ff9" failed (2: No such file or directory) 2022/02/09 07:57:55 [crit] 20533#0: unlink() "/dev/shm/fastcgi-cache/9/1d/34f104b522ce3da5e121512705e071d9" failed (2: No such file or directory) 2022/02/09 07:57:56 [crit] 20533#0: unlink() "/dev/shm/fastcgi-cache/c/f6/20ad25fb54dd7cdba4f5e20ac115ef6c" failed (2: No such file or directory) 2022/03/30 19:54:41 [crit] 4567#0: unlink() "/dev/shm/fastcgi-cache/d/60/130c355ac11e52452f0d30548ebea60d" failed (2: No such file or directory) 2022/04/17 20:44:15 [crit] 16846#0: unlink() "/dev/shm/fastcgi-cache/e/09/7050b1d2f522a1ffc2eee6f0df53f09e" failed (2: No such file or directory) 2022/04/17 20:45:05 [crit] 17337#0: unlink() "/dev/shm/fastcgi-cache/b/cd/94673b5c464bac4f25806e7e9c7aacdb" failed (2: No such file or directory) 2022/04/17 20:45:09 [crit] 17337#0: unlink() "/dev/shm/fastcgi-cache/9/ff/22a613a63da249608fa71acdcd365ff9" failed (2: No such file or directory) 2022/04/17 21:17:23 [crit] 20322#0: unlink() "/dev/shm/fastcgi-cache/f/27/97e2937a9deb199cd42372bb1724327f" failed (2: No such file or directory) 2022/05/08 17:14:19 [crit] 10179#0: unlink() "/dev/shm/fastcgi-cache/d/60/130c355ac11e52452f0d30548ebea60d" failed (2: No such file or directory) 2022/05/18 09:13:15 [crit] 25637#0: unlink() "/dev/shm/fastcgi-cache/f/27/97e2937a9deb199cd42372bb1724327f" failed (2: No such file or directory) 2022/05/18 09:32:56 [crit] 25637#0: unlink() "/dev/shm/fastcgi-cache/8/1a/bd5143be7441d9d4b327f9dfecdec1a8" failed (2: No such file or directory) 2022/05/18 09:55:46 [crit] 25637#0: unlink() "/dev/shm/fastcgi-cache/f/f2/b4d902d28d83339fa906e3634164df2f" failed (2: No such file or directory) 2022/05/18 11:00:40 [crit] 25637#0: unlink() "/dev/shm/fastcgi-cache/d/64/5e717f4e38dd0775d6283890a0f7464d" failed (2: No such file or directory)
Hi @icyb3r.
Please try replace your WooCommerce-specific rules with the following and see if that makes a difference:
if ($request_uri ~* "/(cart|checkout|my-account)/*$") { set $skip_cache 1; }
Additionally, you may also want to review your permission rules for /var/log/nginx folder.
Cheers!
Hi @rynald0s,
Now it seems to be working fine thanks to you ??, but can you tell me what’s wrong with the previous rules? I mean this one:
if ($request_uri ~* "/cart/|/services.*|/store.*|/cart.*|/account.*|/my-account.*|/checkout.*|/addons.*|/panier.*|/paiement.*|/mon-compte.*") { set $no_cache 1; }
And I’ll check the logs permissions.
- The topic ‘How to exclude cart from FastCGI caching?’ is closed to new replies.