Skip to content

Update varnish6.vcl #33604

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

Closed
wants to merge 1 commit into from
Closed

Conversation

ThijsFeryn
Copy link

This is Thijs from Varnish Software.

The set beresp.ttl = 0s should NEVER EVER be used. By setting the TTL to zero seconds, the object will not be stored in the Hit-For-Miss cache.

When the next request for this object is received, Varnish will assume the content is cacheable and will put the request on the waiting list. However, those requests can never be satisfied in parallel. This means every request for a resource that has a status code other than 200 or 404 will be processed serially.

If one of these requests has slow response times, it will slow the entire chain of requests down.

I understand that you want to cater for one-off HTTP 500 requests, because you're afraid they'll end up in the Hit-For-Pass cache for a long time. But this behavior has changed in Varnish 5: as of Varnish 5, Hit-For-Pass has been converted into Hit-For-Miss.

This means that the object will be uncacheable until the Hit-For-Miss TTL expires, or until the next response is deemed cacheable.

My advice is to use the standard TTL as illustrated below:

if (beresp.status != 200 && beresp.status != 404) {
    set beresp.ttl = 120s;
    set beresp.uncacheable = true;
    return (deliver);
}

Please also change this in varnish5.vcl and set the TTL to a lower value in varnish4.vcl.

This is Thijs from Varnish Software.

The `set beresp.ttl = 0s` should NEVER EVER be used. By setting the TTL to zero seconds, the object will not be stored in the *Hit-For-Miss* cache.

When the next request for this object is received, Varnish will assume the content is cacheable and will put the request on the waiting list. However, those requests can never be satisfied in parallel. This means every request for a resource that has a status code other than `200` or `404` will be processed serially.

If one of these requests has slow response times, it will slow the entire chain of requests down.

I understand that you want to cater for one-off HTTP 500 requests, because you're afraid they'll end up in the *Hit-For-Pass cache* for a long time. But this behavior has changed in Varnish 5: as of Varnish 5, *Hit-For-Pass* has been converted into *Hit-For-Miss*. 

This means that the object will be uncacheable until the *Hit-For-Miss* TTL expires, or until the next response is deemed cacheable.

My advice is to use the standard TTL as illustrated below:

```
if (beresp.status != 200 && beresp.status != 404) {
    set beresp.ttl = 120s;
    set beresp.uncacheable = true;
    return (deliver);
}
```

> Please also change this in `varnish5.vcl` and set the TTL to a lower value in `varnish4.vcl`.
@m2-assistant
Copy link

m2-assistant bot commented Jul 27, 2021

Hi @ThijsFeryn. Thank you for your contribution
Here are some useful tips how you can test your changes using Magento test environment.
Add the comment under your pull request to deploy test or vanilla Magento instance:

  • @magento give me test instance - deploy test instance based on PR changes
  • @magento give me 2.4-develop instance - deploy vanilla Magento instance

❗ Automated tests can be triggered manually with an appropriate comment:

  • @magento run all tests - run or re-run all required tests against the PR changes
  • @magento run <test-build(s)> - run or re-run specific test build(s)
    For example: @magento run Unit Tests

<test-build(s)> is a comma-separated list of build names. Allowed build names are:

  1. Database Compare
  2. Functional Tests CE
  3. Functional Tests EE,
  4. Functional Tests B2B
  5. Integration Tests
  6. Magento Health Index
  7. Sample Data Tests CE
  8. Sample Data Tests EE
  9. Sample Data Tests B2B
  10. Static Tests
  11. Unit Tests
  12. WebAPI Tests
  13. Semantic Version Checker

You can find more information about the builds here

ℹ️ Please run only needed test builds instead of all when developing. Please run all test builds before sending your PR for review.

For more details, please, review the Magento Contributor Guide documentation.

⚠️ According to the Magento Contribution requirements, all Pull Requests must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of Pull Requests happens in the queue order. If you want to speed up the delivery of your contribution, please join the Community Contributions Triage session to discuss the appropriate ticket.

🎥 You can find the recording of the previous Community Contributions Triage on the Magento Youtube Channel

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@hostep
Copy link
Contributor

hostep commented Jul 27, 2021

Hi @ThijsFeryn!

This sounds like a duplicate of #28927, but maybe you can convince people over here that this probably should be seen as a higher priority then P4? 🙂

(PS: Really loved your "Oe Magento doen affeceren" talk at PHPWVL some years ago 😉)

@ThijsFeryn
Copy link
Author

ThijsFeryn commented Jul 27, 2021

Hi @ThijsFeryn!

This sounds like a duplicate of #28927, but maybe you can convince people over here that this probably should be seen as a higher priority then P4? 🙂

(PS: Really loved your "Oe Magento doen affeceren" talk at PHPWVL some years ago 😉)

@hostep I looked at the full VCL file suggested by Magento and based on what I've seen I can do a whole other presentation on how to improve Magento's standard VCL file.

Reach out to me on Twitter if you're interested in better VCL files for Magento.

And as far as #28927 is concerned, I noticed @gquintard as on that. He's a colleague of mine.

@mrtuvn
Copy link
Contributor

mrtuvn commented Jul 28, 2021

seem duplicate with mentioned PR as hostep reference

@ThijsFeryn ThijsFeryn closed this Jul 28, 2021
@m2-assistant
Copy link

m2-assistant bot commented Jul 28, 2021

Hi @ThijsFeryn, thank you for your contribution!
Please, complete Contribution Survey, it will take less than a minute.
Your feedback will help us to improve contribution process.

@hostep hostep mentioned this pull request Jul 28, 2021
4 tasks
@ihor-sviziev
Copy link
Contributor

Hi @ThijsFeryn,
Thank you for your contribution!
It's great to see people from the @varnish (Varnish Software) trying to improve varnish configs for Magento. 👍

@sdzhepa @sivaschenko @gabrieldagama, I'm pretty sure the guys from Varnish Software know way better Varnish than most of the Magento community. Can we increase the priority of PRs from @gquintard (also from Varnish Software), test and deliver them?
You can find the list of them here: https://github.com/magento/magento2/pulls/gquintard.

PS: last time I missed that @gquintard from @varnish

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

Successfully merging this pull request may close these issues.

5 participants