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

  • Home
  • SEARCH
  • 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 6960145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:21:52+00:00 2026-05-27T15:21:52+00:00

I ask this question here because I think this is more a regex question

  • 0

I ask this question here because I think this is more a regex question than an actual varnish question.

What I basically want to do, is to define a list of domains that varnish will cache. There is already an answer given to this, but I want to use a different approach.

Varnish: cache only specific domain

Now the code that is used in this answer is the following:

sub vcl_recv {
   # dont cache foo.com or bar.com - optional www
   if (req.http.host ~ "(www)?\.(foo|bar)\.com") {
     pass;
   }
   # cache foobar.com - optional www
   if ( req.http.host ~ "(www)?\.foobar\.com" ) {
     lookup;
   }
}

Now what I want is a little different. I have names with different TLD, but I only want to have the non-www version of the domain cached.

So only mydomain.com, or myotherdomain.nl, or yadomain.net

Any other subdomain can be passed to the backend.

  • 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-27T15:21:53+00:00Added an answer on May 27, 2026 at 3:21 pm

    If I’m reading your question correctly you have a list with multiple versions of the same website, so both http://www.foobar.com AND/OR foobar.com and you want to match ONLY foobar.com

    If so, you need to back reference with (?<!www). So a search that would only match domains without the preceding www would be (?<!www\.)((?:[^.\s]+)\.(?:com|net|nl))

    Hope that helps

    EDIT

    (?<!www\.)((?:[^.\s]+)\.(?:\w{2,3})) if domains are unknown

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

Sidebar

Related Questions

There may be more than one way to ask this question, so here's a
This may be a more math focused question, but wanted to ask here because
maybe it's not so proper to ask this question here... anyway, I'm trying to
Sorry, this's my first time to ask a question here. So, I don't have
I ask this question because I'm not able to test it at the moment.
Probably many coders want to ask this question. it is What's the adventages of
G'day, While having a think about this question here about overdesigning for possible future
This may seem like a weird question but thought I would ask here before
I don't know if I can ask this question here. I usually mistake, but...
I ask this question in anticipation as part of a project. I have experience

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.