• Resolved timo0306

    (@timo0306)


    ENV: Latest WP, latest Cache-Enabler-Version, no other Cache-Plugins installed, Multisite-Installation, NGINX

    TASK: Add security-headers by functions.php, e.g.
    header(‘X-Frame-Options: SAMEORIGIN’);

    PROBLEM: headers won`t be added if cache-enabler caches (what would be the main purpose of this plugin :-))

    DESC: I’ve been investigating an irritating error on our Website: After Adding Security-Headers like Content-Security-Policy or Strict-Transport-Security they went away after a time. At First i blame my hoster: If i changed my predeterminated config for WordPress, all would be fine. After a reload the site, my custom headers went away – after restarting the webserver, all would be fine. If header “X-Cache-Handler: wp” is present – which indicates cache-enabler is fine, my own headers are gone.
    OK – that seems to be a problem with cache-enabler – if cache-enabler delivers cached sites, my own headers are went away.
    Commenting out all lines regarding setting headers from line 46 to 94 in advanced-cache.php would`t solve the problem. Deleting all inside “if ( is_readable( $path_html)” e.g. solved one Problem – headers are fine, but cache-enabler wont work because “// deliver cached file (default) readfile( $path_html );” should be removed too to get working headers.

Viewing 5 replies - 1 through 5 (of 5 total)
  • Have you tried adding the custom headers via your Nginx config instead?

    Thread Starter timo0306

    (@timo0306)

    no, thats not possible. Nginx config is editable by my hoster only, in my account i can only add redirects for nginx.

    By default, the cache enabler bypasses PHP in order to run faster. You can however disable this by going to your wp-config.php file and setting define('WP_CACHE', true); to define('WP_CACHE', false);

    You may see a slight decrease in performance, however this will allow you to process PHP again.

    Thread Starter timo0306

    (@timo0306)

    tnx a lot. Didn’t know what happens exactly if setting WP_CACHE to false, thanks for this information. I got my “A” back on securityheaders.io 🙂 And because of nginx and http2 (and cache enabler of course 🙂 i’m still far below 1s loadtime. Great!

    You can however disable this by going to your wp-config.php file and setting define(‘WP_CACHE’, true); to define(‘WP_CACHE’, false);

    That was a nice little workaround. Thanks.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘own headers are blocked’ is closed to new replies.