0
votes

I have a problem with varnish when my wordpress redirect a page with 302 status.

My environment : Varnish listening on IP1:80 Backend (Apache) listening on IP2:80 Site type : wordpress

Concidering two pages : page1, page2

I have configured a 302 redirection in wordpress from page1 to page2.

But even if page2 is already cached by varnish, when page2 is requested after 302 redirection, varnish doesn't deliver content from the cache but send the request to the backend !

So what is the problem ? How can I fix it ?

Thanks in advance.

1

1 Answers

0
votes

You need to cache page1 response.

I guess your backend is sending some kind of no-cache, max-age or expires header that prevents Varnish caching of the response, since default behaviour is tu cache 302 status codes [1].

Please attach varnishlog of a full request of page1 along with your VCL configuration.

[1] https://www.varnish-software.com/static/book/VCL_Basics.html#the-initial-value-of-beresp-ttl