Last active
August 1, 2017 20:10
-
-
Save lukecav/2e5b24ffda25e897c5bc5f169349607b to your computer and use it in GitHub Desktop.
Cache AJAX GET Requests in Varnish
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
https://guides.wp-bullet.com/how-to-cache-ajax-get-requests-with-varnish-4/