Background Image
Table of Contents Table of Contents
Previous Page  63 / 68 Next Page
Information
Show Menu
Previous Page 63 / 68 Next Page
Page Background

63

REVISTA LOCAWEB

########

return (lookup);

}

# HIT FUNCTION

# ########################

###########################

#######

sub vcl_hit {

# IF THIS IS A PURGE

REQUEST THEN DO THE PURGE

# #######################

###########################

########

if (req.request ==

"PURGE") {

purge;

error 200 "Purged.";

}

return (deliver);

}

# MISS FUNCTION

# ########################

###########################

#######

sub vcl_miss {

if (req.request ==

"PURGE") {

purge;

error 200 "Purged.";

}

return (fetch);

}

# FETCH FUNCTION

# ########################

###########################

#######

sub vcl_fetch {

# I SET THE VARY TO

ACCEPT-ENCODING, THIS

OVERRIDES W3TC

# TENDANCY TO SET VARY

USER-AGENT. YOU MAY OR MAY

NOT WANT

# TO DO THIS

# #######################

###########################

########

set beresp.http.Vary =

"Accept-Encoding";

# IF NOT WP-ADMIN THEN

UNSET COOKIES AND SET THE

AMOUNT OF

# TIME THIS PAGE WILL STAY

CACHED (TTL)

# #######################

###########################

########

if (!(req.url ~ "wp-

(login|admin)") && !req.

http.cookie ~ "wordpress_

logged_in" ) {

unset beresp.http.set-

cookie;

set beresp.ttl = 96h;

}

if (beresp.ttl <= 0s ||

beresp.http.Set-Cookie

||

beresp.http.Vary ==

"*") {

set beresp.ttl = 120

s;

return (hit_for_pass);

}

return (deliver);

}

# DELIVER FUNCTION

# ########################

##########################

########

Sobre o autor

Homero Ottoni é programador e

sócio-proprietário da empresa Make

Media de desenvolvimento web.

LW

Página oficial do Varnish: a ideia dos desenvolvedores é tornar o carregamento de sites muito rápido

[

EXISTEM MUITAS FORMAS DE MODIFICAR

E MELHORAR AS RESPOSTAS AJUSTANDO

DIVERSOS ELEMENTOS DO VARNISH

]

sub vcl_deliver {

# IF THIS PAGE IS

ALREADY CACHED THEN RETURN

A 'HIT' TEXT

# IN THE HEADER (GREAT

FOR DEBUGGING)

# ######################

##########################

##########

if (obj.hits > 0) {

set resp.http.X-Cache

= "HIT";

# IF THIS IS A MISS

RETURN THAT IN THE HEADER

# ######################

##########################

##########

} else {

set resp.http.X-Cache

= "MISS";

}

}