• The following option in Cloudflare: Browser Cache Expiration does not allow you to choose – Respect Existing Headers.

    The application returns: Error: Cloudflare browser cache expiration not set.

    This option is interesting, as it makes more adjustments to the Cache-Control Header on the site and certain pages.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Ante Laca

    (@alaca)

    HI @douglasferraz89

    The application returns: Error: Cloudflare browser cache expiration not set.

    Which application, WPP or Cloudflare?

    Thanks

    Thread Starter Douglas Ferraz

    (@douglasferraz89)

    The error is present in the WPP.

    The Cloudflare API shows that the value 0 is equivalent to selecting “Respect Existing Headers”.

    Read about here: https://api.cloudflare.com/#zone-settings-change-browser-cache-ttl-setting

    In /includes/addons/cloudflare/views/admin.php

    <?php 
                    
                    $options = [
                        30, 60, 300, 1200, 1800, 3600, 7200, 10800, 14400, 18000, 28800, 43200, 57600, 72000, 86400, 172800, 259200, 345600, 432000, 691200, 1382400, 2073600, 2678400, 5356800, 16070400, 31536000 
                    ];
    
                    ?>
    
                    <tr>
                        <td>
                            <strong><?php _e( 'Browser Cache Expiration', 'wpp' ); ?></strong></td>
                        <td>
                            <select name="cf_browser_expire" form="wpp-settings">
                                <option value=""><?php _e( 'Respect Existing Headers', 'wpp' ); ?></option>
                                <?php foreach( $options as $option ): ?>
                                    <option value="<?php echo $option; ?>" <?php wpp_selected( 'cf_browser_expire', $option, 14400 ); ?>>
                                        <?php echo $option; ?>
                                    </option>
                                <?php endforeach; ?>
                            </select>

    There is no defined value for Respect Existing Headers

    This solution seems to work well.

    <?php  
    
    $options = [
    0, 30, 60, 300, 1200, 1800, 3600, 7200, 10800, 14400, 18000, 28800, 43200, 57600, 72000, 86400, 172800, 259200, 345600, 432000, 691200, 1382400, 2073600, 2678400, 5356800, 16070400, 31536000 
    ];
    
    ?>
    
    <tr>
    <td>
    <strong><?php _e( 'Browser Cache Expiration', 'wpp' ); ?></strong></td>
    <td>
    <select name="cf_browser_expire" form="wpp-settings">
    	<?php foreach( $options as $option ): ?>
    		<option value="<?php echo $option; ?>" <?php wpp_selected( 'cf_browser_expire', $option, 0 ); ?>>
    		<?php if ($option == 0): ?>
    			<?php _e( 'Respect Existing Headers', 'wpp' ); ?>
    		<?php else: ?>
    			<?php echo $option; ?>
    		<?php endif; ?>
    		</option>
    	<?php endforeach; ?>
    </select>
    Thread Starter Douglas Ferraz

    (@douglasferraz89)

    Hi @alaca

    I’m sorry if the code here gets bad to read;

    I could have opened the problem on Github.

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Error in Cloudflare’ is closed to new replies.