Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub vcl_recv {
- # Set backend
- set req.backend = default;
- if (req.http.host ~ "gitweb.squeezebox.vm") {
- return (pass);
- }
- # Set a unique cache header with client ip
- if (req.http.x-forwarded-for) {
- set req.http.X-Forwarded-For = req.http.X-Forwarded-For + ", " + client.ip;
- } else {
- set req.http.X-Forwarded-For = client.ip;
- }
- # Always allow post request to be sent to the backend but not cached
- if (req.request == "POST") {
- ban("req.url == " + req.url);
- set req.http.X-Test = req.url;
- return (pass);
- }
- if (req.request != "GET" &&
- req.request != "HEAD" &&
- req.request != "PUT" &&
- req.request != "POST" &&
- req.request != "TRACE" &&
- req.request != "OPTIONS" &&
- req.request != "DELETE") {
- # Pass to backend until it's closed
- return (pipe);
- }
- # If neither get nor post request, send to backend but not cached
- if (req.request != "GET" && req.request != "HEAD") {
- return (pass);
- }
- # If any autorisation was set do not cache
- if (req.http.Authorization || req.http.Cookie ~ "fe_typo_user") {
- return (pass);
- }
- # If we work in backend
- if (req.http.Cookie ~ "be_typo_user") {
- # Delete cache depending on TYPO3 cache control
- if (req.http.Cache-Control ~ "no-cache") {
- set req.ttl = 0s;
- ban("req.url == " + req.url);
- }
- return (pass);
- }
- else {
- # Delete cookie
- unset req.http.Cookie;
- }
- # Lookup in cache
- return (lookup);
- }
- sub vcl_fetch {
- # Set default cache to 12 hours
- set beresp.ttl = 12h;
- # Deliver old content up to 1 day
- set req.grace = 24h;
- # Set cache for 2 days
- if (req.url ~ "\.(jpeg|jpg|png|gif|ico|swf|js|css|txt|gz|zip|rar|bz2|tgz|tbz|html|htm|pdf|pls|torrent)$") {
- set beresp.ttl = 48h;
- }
- # Delete cookie
- if (req.url ~ "^/typo3") {
- }
- else {
- if (req.request == "POST") {
- }
- else {
- unset beresp.http.Set-Cookie;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement