Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Still issue with add to cart - the second time it works #38

Open
musab1 opened this issue Nov 13, 2015 · 8 comments
Open

Still issue with add to cart - the second time it works #38

musab1 opened this issue Nov 13, 2015 · 8 comments

Comments

@musab1
Copy link

musab1 commented Nov 13, 2015

Hi all

I've read all the READMEs and all the posts in the other issues (and tryed/implemented everything out).

I have the problem (since this form_key disaster) that the add to cart still doesnt work.

The first time i try to add something to the card it shows an empty cart - and the EXTERNAL_NO_CACHE cookie get set (and then afterwards it works, becouse
its bypassing Varnish becouse of the cookie).

I can not figure out what the problem is becouse the PAGECACHE_FORMKEY cookie is getting set right, and the html sourcecode shows the same key.
so its not like this esi tags didnt get replaced.

@musab1
Copy link
Author

musab1 commented Nov 13, 2015

a small Update: when i set the external_no_cache cookie manualy, it still doesnt work.
so it must be something else - related to this form_keys or whatever.

@Guard1an
Copy link

Was having the same issue, but it disappeared after I removed tricks I've done with cookies in default.vcl.
Check whether PAGECACHE_FORMKEY cookie is really passed to backend (log cookies in checkout/cart/add controller action)

BTW: I found out that Varnish relies on Vary: User-Agent headers so removing them will make your caching proxy not to clone cache of the same content for different browsers.

Try to enable module debug option and check X-Cache* headers in different browsers. After baning the cache and accessing the same url from different browsers you will see 0 hits and X-Cache:MISS. That happens because Varnish relies on Vary: User-Agent header sent by Magento. If your application doesn't rely on User-Agent (content is the same on all devices and depends on URL or session only) you can solve User-Agent issue by adding the following lines to sub vcl_recv of default.vcl

    if (beresp.http.Vary ~ "User-Agent") {
        set beresp.http.Vary = regsub(beresp.http.Vary, ",? *User-Agent *", "");
        set beresp.http.Vary = regsub(beresp.http.Vary, "^, *", "");
        if (beresp.http.Vary == "") {
            unset beresp.http.Vary;
        }
    }

P.S.: I removed my previous concerns regarding Cookies finding them wrong. default.vcl provided with VarnishCache module makes Varnish to cache content even if Cookie request header is present.

Sincerely yours,
Andrew Storozhev

@Emulator000
Copy link

Hi @Guard1an, could you provide more information about this approach? I'm experiencing the same annoying issue without have found a solution yet! Thank you very much!

@phoenix-bjoern
Copy link
Contributor

Make sure you've disabled "Browser Capability Check" for cookies in the Magento configuration (General/Web).

@Emulator000
Copy link

Thank you for you reply @phoenix-bjoern, anyway I can't find this exact option, what I've on the backend is:
untitled

Thanks!

@phoenix-bjoern
Copy link
Contributor

It is "Redirect to CMS-page if Cookies are Disabled".

@Emulator000
Copy link

Thanks @phoenix-bjoern, I'm just making some test and I will let you know.

@Emulator000
Copy link

I can confirm that the suggested option by @phoenix-bjoern resolve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants