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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:45:04+00:00 2026-06-12T21:45:04+00:00

I am using Varnish 3.0.3 and to use it to leverage browser caching by

  • 0

I am using Varnish 3.0.3 and to use it to leverage browser caching by setting a maximum age in the HTTP headers for static resources. I tried adding the following configuration to default.vcl:

sub vcl_fetch {
  if (beresp.cacheable) {
    /* Remove Expires from backend, it's not long enough */
    unset beresp.http.expires;

    /* Set the clients TTL on this object */
    set beresp.http.cache-control = "max-age=900";

    /* Set how long Varnish will keep it */
    set beresp.ttl = 1w;

    /* marker for vcl_deliver to reset Age: */
    set beresp.http.magicmarker = "1";
  }
}

sub vcl_deliver {
  if (resp.http.magicmarker) {
    /* Remove the magic marker */
    unset resp.http.magicmarker;

    /* By definition we have a fresh object */
    set resp.http.age = "0";
  }
}

This is copied from https://www.varnish-cache.org/trac/wiki/VCLExampleLongerCaching . Maybe I just made a typo. On restart of Varnish, it no longer worked.

I have two questions. Is this the correct way to do it for Varnish 3? If so, what am I doing wrong? Secondly, is there a way to test the Varnish configuration file, before a restart? Something along the ways of what Apache has with “/sbin/service httpd configtest”. That catches mistakes before going live. Thank you.

  • 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-06-12T21:45:05+00:00Added an answer on June 12, 2026 at 9:45 pm

    Yes, in general this is the way of overriding the backend’s TTL.
    Remove beresp.http.expires, set beresp.http.cache-control, set beresp.ttl.
    beresp.cacheable is a 2.[01]-ism. The same test in 3.0 is to check that beresp.ttl > 0.

    A small tip is to store your magic marker on req.http instead, then you don’t have to clean it up before handing the object to the client.

    With regards to testing a configuration file, you can call the VCL compiler directly with “varnishd -C -f /etc/varnish/default.vcl” for example. If your VCL is faulty you get the error message, if the VCL is valid you get a few pages with generated C code.

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

Sidebar

Related Questions

I want to purge Elements of my varnish using HTTP. This http call is
My goal is to use Varnish to cache my static assets with my Symfony
Hey everybody. I'm using Edge Side Includes on Varnish to cache a static HTML
I'm studying how to use caching in Heroku for my Rails app. HTTP cache
I'm using varnish to cache the content of my websites. It is working as
I am using varnish 3.0 on ubuntu 11 - the redirect is being handled
using this http://bl.ocks.org/950642 we can see how to add images to nodes, the question
We use varnish as our load balancer (among other things) but we get some
i use this example as a base: http://jqueryui.com/demos/autocomplete/#combobox its cool. But if you type
I'm using varnish with -s malloc,1G" It's currently 98% full. Once it completely full

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.