• Hi,

    I have a particular situation where some pages are accessible for visitors, but if that visitor has a certain propriety they are redirected away from that page to a different one.

    Let’s say you want to access /something as a regular visitor, that will work fine. But if you want to access /something as a visitor with a certain cookie you will be sent to /something-else.

    I use wp_rediect() for that and I feel like this behavior gets cached. If I clear the cache (fresh cache now on the site) and a user with that particular cookie gets on the /something is sent to /something-else. Next time a normal visitor gets to /something they are sent to /something-else, giving me the impression that the redirect is cached from the first user.

    I tried adding nocache_headers before the wp_redirect(), but doesn’t seem to change anything.

    Of course, I could do the redirects in JS and get past this, but I don’t want to actually load the page and do the redirect like that.

    Is this something that can be adjusted from W3 settings or am I missing something?

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @necroob

    Thank you for reaching out and I am happy to help!
    If the pages you are redirecting to are the part of the website on which the W3 Total Cache is enabled on, those pages will be cached once visited.
    So it’s not specifically related to the ?wp_rediect() but the fact that the caching is e=nabled.

    Is the page you are redirecting to outside of the website?

    You can exclude pages from caching in Performance>Page Cache>Advanced, and add those pages to exclusion from caching.
    Let me know if this helps!
    Thanks!

    Thread Starter George-Paul Cre?u

    (@necroob)

    @vmarko Thanks for getting back to me.
    Yes, this might be it. I went over the settings to see if this is listed in the page exclusion section, and the particular page we were interested in was missing from the list in Prod, but it was on Staging.

    Thanks!

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello (@necroob

    You are most welcome!

    We would really appreciate it if you could take a minute and post a review here. This will help us to continue offering a top-notch product to users.
    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Are PHP redirects and ‘wp_redirect()’s being cached?’ is closed to new replies.