Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7497009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:53:24+00:00 2026-05-29T18:53:24+00:00

I’m an absolute newbie to Varnish & caching in general, so this question might

  • 0

I’m an absolute newbie to Varnish & caching in general, so this question might be trivial to some !

I’m building a web app (in rails), and I was looking at some options to cache content on production servers. I’ve so far looked at Varnish, and am slightly concerned about the non-caching of with-cookie requests. I understand why such a behaviour is intended, but there is one use-case that could really benefit if there was some way to cache content over cookies.

In my particular case, a lot of urls have data that is same irrespective of the logged-in user. For example, tripadvisor would possibly be returning every logged-in user the same data (at least majority of the data) for a hotel listing. So essentially, although cookies would accompany the request / response, about 90% of the page would be common for each user.

In such scenarios, is it possible to use Varnish to cache such urls / pages (maybe the common part only). And if yes, then how.

Thanks a ton !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T18:53:25+00:00Added an answer on May 29, 2026 at 6:53 pm

    If I understood your use case correctly. You would like to cache a subset of pages even in presence of cookies because those pages will be the same for all users.

    The best way to do this would be to identify the pages you want to cache all the time, let’s say /foo.html and /bar.html. For those pages you can remove the Cookie request header in VCL so Varnish can cache the page.

    You can use the following VCL code as an example:

    sub vcl_fetch {
        [...]
        if(req.url ~ "/foo.html" || req.url ~ "/bar.html") {
            unset req.http.Cookie
        }
    
        [...]
        if (req.http.Authorization || req.http.Cookie) {
            /* Not cacheable by default */
            return (pass);
        }
    }
    

    If you have much more pages you can use a regular expression in the if condition to match you page names.

    If you want to only cache parts of a page then you can use ESI since it is supported (the support is limited but sufficient) by Varnish but this requires you to rewrite part of your application and IMHO using ESI is really a PITA in the long run (harder maintenance).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
We're building an app, our first using Rails 3, and we're having to build
I have some data like this: 1 2 3 4 5 9 2 6
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.