I have installed varnish cache in my server

Caching and its TTL working good

But the system create new cache object and age for every visitor

How can I config the system to create one cache object for all visitors ?

Thanks a lot


I found the answer in this page


Why does Varnish keep a separate version in cache for each browser?

The backend issues a "Vary: User-Agent" which explicitly tells Varnish too keep a separate version of the page for each User-Agent. Reconfigure your backend server or overwrite the header in vcl_fetch.

  • I would be very surprised if your application use the Vary header for identifying visitors. Can you really imagine that you set different User-Agent for every single visitor?
    – karatedog
    Apr 16 '16 at 23:40

Without telling us more what every visitor means, it is quite good that Varnish creates new objects for every one of them.

Otherwise if I log in to your system, it might greet me with "Welcome Egyptian", if I happen to log in after you, because it is reusing a cached object, that has been created by your login.

How does your visitors URL look like? If it contains username, then it is natural that varnish creates new objects for them.

  • your reply is correct, But I don't use any membership in my site, No need to change the contents for every visitor
    – Mostafa
    Apr 19 '16 at 3:04
  • Let's challenge the original problem. How do you know that varnish creates new objects? Can you post the headers of two subsequent requests?
    – karatedog
    Apr 19 '16 at 7:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.