• Resolved Managedserver.it

    (@dreamsnet)


    Hi everyone,

    We recently encountered an issue with JetPack that negatively impacts the ability of Full Page Cache (FPC) systems like Varnish, Nginx FastCGI Cache, or NGINX Proxy Cache to correctly cache HTML pages.

    Specifically, JetPack is setting a client-side cookie named woocommerceanalytics_session, which is sent along with HTTP requests via the Set-Cookie header.How Cookies Affect FPC

    When a cookie is sent in the server’s response to the client (via Set-Cookie), caching systems like Varnish tend to treat the response as uncacheable. This happens because cookies indicate that the content may be user-specific or dynamic, which conflicts with the idea of static content shared among users.

    A typical scenario with Varnish:

    • When the browser sends an HTTP request and receives a Set-Cookie header in the response, Varnish applies default policies that exclude the page from caching.
    • This means every request for that page will hit the backend, reducing cache efficiency and increasing response times.

    Solution: Disable or Unset the Cookie

    The only way to ensure the cache works correctly is to remove the cookie. Here’s an example of how to do this in Varnish:

    In the VCL configuration file:

    sub vcl_recv {
    if (req.http.Cookie) {
    # Rimuove il cookie specifico
    set req.http.Cookie = regsuball(req.http.Cookie, "(^|;)\swoocommerceanalytics_session=[^;]", "");
    # Rimuove eventuali cookie vuoti residui
    if (req.http.Cookie ~ "^\s*$") {
    unset req.http.Cookie;
    }
    }
    }

    With this configuration, Varnish ignores the woocommerceanalytics_session cookie, allowing the HTML responses to be cached.Conclusion

    If you’re using JetPack and experiencing issues with FPC, check the cookies set in the HTTP response headers. The woocommerceanalytics_session cookie is likely the culprit. By disabling or ignoring this cookie, you can restore the proper functionality of static page caching.

    I hope this information is helpful! If you have any questions or want to share your experiences, feel free to comment below.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Alin (a11n)

    (@alinclamba)

    Hi @dreamsnet,

    Thank you for reaching out and for the details provided.

    This has been fixed in the latest version of Jetpack 14.2.1. Please update the plugin and let us know how it goes.

    Best regards,
    Alin

    Plugin Contributor Stef (a11n)

    (@erania-pinnera)

    Hey there, @dreamsnet,

    Do you have updates about that, do you still need help? We usually close inactive threads after one week of no movement, but we want to make sure we’re all set before marking it as solved. Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘woocommerceanalytics_session and Cache Server Side’ is closed to new replies.