Open heyyoyo opened 8 years ago
Well IIRC when you add something to the cart you get a session, this means a cookie so that the connection between the client and the server can be made. There should be no caching at all. Is your cart the standard cart or you're using something else?
Thanks for your answer, my cart is the standard, except the design. I do see the cookie SESS for the anonymous user. Please find my website, here is a product page just use the add to cart and click on the cart. http://new.israelmodernart.com/1948 You will see that the cart is empty. But if you go to the cart page you will see it's not. http://new.israelmodernart.com/cart
If I disable microcache, its working as expected.
Not sure what to do
@heyyoyo I cannot reproduce your issue. I went to your shop added the 1948 item to my cart. Reloaded the page multiple times. The cookie is there and the cart has the item in it. I went to /shop
the same appears.
Here's the headers in chrome dev tools:
Cache-Control:no-cache, must-revalidate, post-check=0, pre-check=0
Connection:keep-alive
Content-Encoding:gzip
Content-Language:en
Content-Type:text/html; charset=utf-8
Date:Thu, 08 Oct 2015 21:56:27 GMT
Expires:Sun, 19 Nov 1978 05:00:00 GMT
Keep-Alive:timeout=10
Link:<http://new.israelmodernart.com/shop>; rel="canonical",<http://new.israelmodernart.com/shop>; rel="shortlink"
Server:nginx
Transfer-Encoding:chunked
Vary:Accept-Encoding
X-Content-Options:nosniff
X-Micro-Cache:EXPIRED
X-Powered-By:PHP/5.6.14-1+deb.sury.org~trusty+1
Request Headers
view source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8,fr-FR;q=0.6,fr;q=0.4,pt-PT;q=0.2,pt;q=0.2,es;q=0.2,de-DE;q=0.2,de;q=0.2
Cache-Control:no-cache
Connection:keep-alive
Cookie:SESSc46dea5646c20b88d33b50c9b3b725b4=VipCg8laZh_ttYoPPVnA2Uywn3KYZK1b0Efm6bivyEE; has_js=1
Host:new.israelmodernart.com
HTTPS:1
Pragma:no-cache
Referer:http://new.israelmodernart.com/1948
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.89 Safari/537.36
In a different tone, you should disable the X-Powered-By
header in php-fpm. Or if you want to do it in nginx add:
fastcgi_hide_header X-Powered-By;
to the fastcgi_drupal.conf
file in the apps
directory.
@perusio thanks for your help. I see in your header that x-micro-cache is expired, For HTTP code 200, it was set to 15s, I passed it to 60s. It could be that you couldn't reproduce my error, just because this time elapsed.
You should be able to reproduce this error easily, on the cart page by just removing an item: http://new.israelmodernart.com/cart
You will see that removing an item won't work the first time, but afters serval times it does works.
Header which doesn't have any effect:
Request Method:GET
Status Code:200 OK
Response Headers
view source
Cache-Control:no-cache
Connection:keep-alive
Content-Encoding:gzip
Content-Language:en
Content-Type:text/html; charset=utf-8
Date:Fri, 09 Oct 2015 05:41:48 GMT
Expires:Thu, 01 Jan 1970 00:00:01 GMT
Keep-Alive:timeout=10
Link:<http://new.israelmodernart.com/cart>; rel="canonical",<http://new.israelmodernart.com/cart>; rel="shortlink"
Server:nginx
Transfer-Encoding:chunked
Vary:Accept-Encoding
X-Content-Options:nosniff
X-Micro-Cache:HIT
Request Headers
view source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate, sdch
Accept-Language:en-US,en;q=0.8,fr;q=0.6
Cache-Control:max-age=0
Connection:keep-alive
Cookie:Drupal.tableDrag.showWeight=0; Drupal.toolbar.collapsed=0; SESSc46dea5646c20b88d33b50c9b3b725b4=Tx9qa-bp_m3RFOd0y75_hXKpH7IZHA0pFMJQGS8RsXw; has_js=1
Host:new.israelmodernart.com
Referer:http://new.israelmodernart.com/cart
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36
Header which works(after 60s):
Request Method:POST
Status Code:200 OK
Response Headers
view source
Cache-Control:no-cache
Connection:keep-alive
Content-Encoding:gzip
Content-Language:en
Content-Type:text/html; charset=utf-8
Date:Fri, 09 Oct 2015 05:41:50 GMT
Expires:Thu, 01 Jan 1970 00:00:01 GMT
Keep-Alive:timeout=10
Link:<http://new.israelmodernart.com/cart>; rel="canonical",<http://new.israelmodernart.com/cart>; rel="shortlink"
Server:nginx
Transfer-Encoding:chunked
Vary:Accept-Encoding
X-Content-Options:nosniff
Request Headers
view source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8,fr;q=0.6
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:152
Content-Type:application/x-www-form-urlencoded
Cookie:Drupal.tableDrag.showWeight=0; Drupal.toolbar.collapsed=0; SESSc46dea5646c20b88d33b50c9b3b725b4=Tx9qa-bp_m3RFOd0y75_hXKpH7IZHA0pFMJQGS8RsXw; has_js=1
Host:new.israelmodernart.com
Origin:http://new.israelmodernart.com
Referer:http://new.israelmodernart.com/cart
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/45.0.2454.101 Safari/537.36
Form Data
view source
view URL encoded
form_build_id:form-PWn0Z9RYEbW_dq5k8CZ8OlZe8epqYNIoSpq3jqTQuSo
form_id:views_form_commerce_cart_form_default
edit_quantity[0]:1
delete-line-item-0:X
We could 3 differences when it finally works: X-micro-cache is not received at all. the request method is not GET but POST POST form data is sent
I finally found my bug, I was using the same nginx configuration for drupal 6. And in the file map_ccache.conf, I was not disabling cache for ajax and cookies
You can remove X-Powered-By from even being generated by setting this in php.ini:
expose_php = off
Then, no need to hide the header in nginx because it never gets generated.
I'm expecting some issue with microcache and drupal commerce.
Adding product to cart, should redirect to the same product page with content slightly modified for the cart section and a drual message telling "product added to cart". But instead Nginx severs the same microcached version of the product page.
In the network panel I could see : _this request when clicking add to cart: _ Request URL:http://MYDOMAIN.com/myproduct-url Request Method:POST Status Code:302 Moved Temporarily
\ and then ** Request URL:http://MYDOMAIN.com/myproduct-url Request Method:GET Status Code:200 OK
\ with response header: ** Cache-Control:no-cache Connection:keep-alive Content-Encoding:gzip Content-Language:en Content-Type:text/html; charset=utf-8 Date:Thu, 08 Oct 2015 07:01:42 GMT Expires:Thu, 01 Jan 1970 00:00:01 GMT Keep-Alive:timeout=10 Link:http://MYDOMAIN.com/1948; rel="canonical",http://MYDOMAIN.com/node/725; rel="shortlink" Server:nginx Transfer-Encoding:chunked Vary:Accept-Encoding X-Content-Options:nosniff X-Micro-Cache:HIT X-Powered-By:PHP/5.5.9-1ubuntu4.5
I also have same issue when deleting/updating products from the cart