Skip to content

Instantly share code, notes, and snippets.

@lukecav
Last active August 1, 2017 20:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukecav/2e5b24ffda25e897c5bc5f169349607b to your computer and use it in GitHub Desktop.
Save lukecav/2e5b24ffda25e897c5bc5f169349607b to your computer and use it in GitHub Desktop.
Cache AJAX GET Requests in Varnish
sub vcl_recv {
# Possibility to cache admin-ajax GET requests
if ((req.url ~ "admin-ajax.php") && !req.http.cookie ~ "wordpress_logged_in" ) {
return (hash);
}
#set the length of time to cache ajax GET requests
if ((bereq.url ~ "admin-ajax.php") && !bereq.http.cookie ~ "wordpress_logged_in" ) {
unset beresp.http.set-cookie;
set beresp.ttl = 1d;
set beresp.grace = 1d;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment