• In PHP I am setting a header() with Access-Control-Allow-Origin.
    Unfortunately this header is stripped out when I enable WP Super Cache. I even checked the “Cache HTTP headers with page content” setting in advanced, but the problem persisted.

    How do I get WP Super Cache to maintain my pages with each of their unique HTTP headers?

Viewing 3 replies - 1 through 3 (of 3 total)
  • You can use the “wpsc_known_headers” filter to modify the array of verified headers. You can add your header to that and it will be cached.

    Thread Starter MarcusSea

    (@marcussea)

    Thank you for the response. I was able to get this working properly. For anyone interested I used something similar to the following before the header of the page was included.

    $my_cors_url = "https://example.com";
    function my_cors_header($known_headers) {
        global $my_cors_url;
        header("Access-Control-Allow-Origin: $my_cors_url");
        return $known_headers;
    }
    add_filter('wpsc_known_headers', 'my_cors_header');
    • This reply was modified 7 years, 6 months ago by MarcusSea.

    That’s not how it works though. In the function you should only have:

    $known_headers[] = 'Access-Control-Allow-Origin';
    return $known_headers;

    You set the header elsewhere, earlier in the process.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘CORS Header Removed from Cache’ is closed to new replies.