Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Varnish: Misc

.vcl rule to pass no content

 

 

Varnish misc RSS feed   Index | Next | Previous | View Threaded


joshua.strebel at gmail

Dec 9, 2011, 12:24 AM

Post #1 of 3 (511 views)
Permalink
.vcl rule to pass no content

Looking for the best way to not cache content that is an empty page.

From time to time a page will return blank, not even an html tag. I need to make sure we pass on these.

Is there .vcl for checking body size? We are using Varnish 3+
--
Joshua Strebel
Founder @ Page.ly

twitter: @strebel








_______________________________________________
varnish-misc mailing list
varnish-misc [at] varnish-cache
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-misc


rlane at ahbelo

Dec 9, 2011, 9:25 AM

Post #2 of 3 (453 views)
Permalink
Re: .vcl rule to pass no content [In reply to]

The should work for you if you get a content type and length from backend. This works on varnish 2.15

I placed this is my fetch block.

# Don't cache html objects smaller than 100 bytes
if ((beresp.status == 200) && (beresp.http.Content-Length ~
"^([0-2]|\d)\d") && ( beresp.http.Content-type ~ "html") ) {
log "TooSmall: Pass on ( " req.url " ) small objects: " beresp.http.Content-Length ;
return(pass);
}

Richard


rlane at ahbelo

Dec 9, 2011, 11:06 AM

Post #3 of 3 (454 views)
Permalink
Re: .vcl rule to pass no content [In reply to]

Joshua,

Actually the code I sent looks for a length that is 299 bytes or smaller. So if you wanted to look for less you would need to change up the regex on Content-Length to something like

If less than 10 bytes - ^[0-9]
If less than 30 bytes - ^[0-2]\d

However this may not work for you either because the Content-Length includes headers also. I will give your question a little more thought.

Cheers,
Richard

On 12/9/11 11:25 AM, "Lane, Richard" <rlane [at] ahbelo> wrote:

The should work for you if you get a content type and length from backend. This works on varnish 2.15

I placed this is my fetch block.

# Don't cache html objects smaller than 100 bytes
if ((beresp.status == 200) && (beresp.http.Content-Length ~
"^([0-2]|\d)\d") && ( beresp.http.Content-type ~ "html") ) {
log "TooSmall: Pass on ( " req.url " ) small objects: " beresp.http.Content-Length ;
return(pass);
}

Richard

Varnish misc RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.