cloudflare / templates

A collection of starter templates and examples for Cloudflare Workers and Pages
https://cloudflareworkers.com
MIT License
999 stars 632 forks source link

Cannot modify header information #43

Closed cathexisvideo closed 5 years ago

cathexisvideo commented 5 years ago

Hello.

I'm receiving the following warnings in my logs, how would I resolve this, any suggestions?

PHP Warning: Cannot modify header information - headers already sent in /wp-content/plugins/cloudflare-page-cache/cloudflare-page-cache.php on line 26

I worked through this a bit without much success: https://stackoverflow.com/questions/8028957/how-to-fix-headers-already-sent-error-in-php

Thank you

kolyasapphire commented 5 years ago

Hi, this could be because a header is also added to cron requests, try adding a check for cron:

if ( !defined( 'DOING_CRON' ) )
{
  if (!is_user_logged_in() ) {
    header( 'x-HTML-Edge-Cache: cache,bypass-cookies=wp-|wordpress|comment_|woocommerce_' );
  } else {
    header( 'x-HTML-Edge-Cache: nocache' );
    }
}
cathexisvideo commented 5 years ago

Thank you so much Kolyasapphire, that worked :)