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

First Request is never cached #957

Closed
thampe opened this issue Sep 23, 2015 · 7 comments
Closed

First Request is never cached #957

thampe opened this issue Sep 23, 2015 · 7 comments
Assignees

Comments

@thampe
Copy link

thampe commented Sep 23, 2015

Hi,

every new request without a frontend cookie can be not cached.

Relevant snippet from version-3.vcl:

# no frontend cookie was sent to us AND this is not an ESI or AJAX call
if (req.http.Cookie !~ "frontend=" && !req.http.X-Varnish-Esi-Method) {
    if (client.ip ~ crawler_acl ||
            req.http.User-Agent ~ "^(?:{{crawler_user_agent_regex}})$") {
        # it's a crawler, give it a fake cookie
        set req.http.Cookie = "frontend=crawler-session";
    } else {
        # it's a real user, make up a new session for them
        {{generate_session}}# call generate_session;
        return (pipe);
    }
}

Since the last two versions (0.6.5 and 0.6.6) when no frontend-cookie is present the request goes straight to the backend server (return (pipe)). This a bit of a problem for our shop, since most first requests go to a page where a vaild form_key and CSFR protection is not really necessary, but a fast page load is.

As always thanks for your help.

@csdougliss
Copy link
Contributor

@thampe Was going to look into this. I've noticed a jump in first page load time too

@addison74
Copy link

I confirm this issue. Even the cache is warmed by other visitors, always the first time page visit takes a lot of time to load.

@csdougliss
Copy link
Contributor

I think this is because return pipe should only be the case if session generation is turned off in varnish

@csdougliss
Copy link
Contributor

#959

@miguelbalparda
Copy link
Contributor

Have you seen #924 @thampe @craigcarnell @addison74?

@thampe
Copy link
Author

thampe commented Sep 23, 2015

Yes I have seen the issue, I think @craigcarnell solution (#959) is smarter and fits better for certain setups. Most pages have a seo-freindly url and can not be matched reliably with a reg-ex.

@miguelbalparda
Copy link
Contributor

Merged into devel, feel free to try this and please let us know if you find any issues.

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

No branches or pull requests

4 participants