Site logo

Archived topic

Setting no cache headers for specific pages

2 replies · Started by David on May 6, 2020

Viewing posts 1–3 of 3

I have an issue where users navigate through a page, log in, return to that page, and receive a cached version without logged in content. I need to turn off the caching for those pages. Adding the following to my functions.php file worked but it applies to all pages and makes my site slow. How can I apply this only to those pages, or only for logged in users? Thank you so much for any help on this.

header("Cache-Control: no-cache, no-store, must-revalidate"); // HTTP 1.1.
header("Pragma: no-cache"); // HTTP 1.0.
header("Expires: 0"); // Proxies.

Preferably this would apply only to both logged in users who are on those pages.

Hi there,

How are you caching things? It's likely something that needs to be adjusted inside your caching plugin/server caching configuration.

The theme itself doesn't do any caching.

This archived topic is closed to new replies.