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 7041505
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:03:14+00:00 2026-05-28T02:03:14+00:00

Varnish scripting seems rather robust for the vcl but I can’t yet figure out

  • 0

Varnish scripting seems rather robust for the vcl but I can’t yet figure out how to make it do what I need. I run various sites from the same code base and I want a unified varnish cache for most of the directories so

x.mysite.org/theme/something.gif and y.mysite.org/theme/something.gif should not store two copies of the same gif in varnish cache

However

x.mysite.org/file.php/1 and y.mysite.org/file.php/1 should have separate caches based on the url.

Also mysite.org is a whole other site that has its own cache.

My current direction is as follows

sub vcl_fetch {
  if (req.url ~ ".*\.org/file\.php") {
    # do normal site specific caching
  } elseif (req.url ~ "^+?\.mysite.org") {
    # cache all found material in a base directory so everyone knows where to look
    set req.url = regsub(req.url, "(.*\.org)(.*)", "base.mysite.org\2");
  } else {
    # do normal site specific caching for base site
  }
}

sub vcl_recv {
  # do I need to do something here to look in base.mysite.org
}

I can make base.mysite.org a real apache served site if necessary so the requests can fall through if no cache.

Am I on the write path, any help.

  • 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-28T02:03:15+00:00Added an answer on May 28, 2026 at 2:03 am

    You should normalize req.http.host instead of req.url, so

    sub vcl_fetch {
      # if it starts with /theme or /static, or contains .gif,.png etc, 
      #   then consider the host to the normalized/common host
      if (req.url ~ "^/(theme|static)" || req.url ~ "\.(gif|png)" ) {
        set req.http.host = "base.mysite.org";
        return (lookup);
      }
      # else, do non shared stuff here
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been trying like mad to figure out the VCL for how to do
Here is my situation. I am testing out Varnish on my local box (I'm
i'm trying to figure out where Windows Error Reports are saved; i hit Send
We use varnish as our load balancer (among other things) but we get some
I'm currently working on a Varnish (v3) set up, but I was wondering if
Can Varnish distribute its cache to multiple machines? For example, if the amount of
Can we use Mobile Tools module in Drupal6 with Varnish? I doubt varnish will
I know modules like Mobile Tools can do what I want - but they
I have a relatively simple (I think) use-case but I can't find any examples
I'm looking for a caching reverse proxy (something like squid or varnish) with good

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.