{"id":19034035,"date":"2026-10-01T12:19:09","date_gmt":"2026-10-01T12:19:09","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/add-custom-csp-policy-to-headers\/"},"modified":"2026-10-01T12:19:09","modified_gmt":"2026-10-01T12:19:09","slug":"add-custom-csp-policy-to-headers","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/add-custom-csp-policy-to-headers\/","title":{"rendered":"Add custom CSP policy to headers"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hello,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We are using your <strong>WP Super Cache<\/strong> plugin and we would like to ask about an issue we are experiencing.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We believe that cached pages and posts are not returning a header related to our <strong>Content Security Policy (CSP)<\/strong>. We add this CSP through a custom <strong>mu-plugin<\/strong> using the <code>send_headers<\/code> hook.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Is it possible that when a page is served from cache, the <code>send_headers<\/code> hook is not executed?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We only use caching for anonymous users. Logged-in users do not receive cached pages, and for those users everything works correctly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Does WP Super Cache provide any plugin-specific hook that allows custom headers to be added to cached pages or posts?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Alternatively, is there any way from within WordPress to define this CSP header that would also work when WP Super Cache is active, without relying on the <code>send_headers<\/code> hook?<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Thank you very much for your help.<\/p>\n","protected":false},"template":"","class_list":["post-19034035","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19034035","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/19034035\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=19034035"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}