Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author George Notaras

    (@gnotaras)

    Hello,

    I’m sorry for the late reply. You can prevent the ‘Expires’ header from being sent by setting the relevant option to false in the options. For example, add the following in your theme’s functions.php file:

    function addh_custom_options ( $options ) {
        return array_merge( $options, array(
            'add_expires_header' => false,
        ) );
    }
    add_filter( 'addh_options', 'addh_custom_options', 10, 1 );

    Regarding the Pragma header, there is no option to exclude that because this header is only taken into account by HTTP 1.0 clients, so it is always sent together with the Cache-Control header (for HTTP 1.1 clients).

    Although it is very possible to exclude it right now programmatically, I’ll consider adding an option for that header in the next release.

    Feel free to ask any questions about the code above.

    Kind Regards,
    George

    Plugin Author George Notaras

    (@gnotaras)

    Although the Pragma header is needed in several cases, I’m considering to add an explicit option in 1.2.1 to be able to stop sending it.

    George

    Plugin Author George Notaras

    (@gnotaras)

    The Pragma header is actually tied to the Cache-Control header. So, it wouldn’t make sense to add an explicit option for it. I’d really like to read some more details about why this is needed.

    Usually, I add extra configuration options only whenever there is a valid reason for doing so. I’m looking forward to your feedback.

    George

    Plugin Author George Notaras

    (@gnotaras)

    Hi, not sure if you are still following this topic, but I just wanted to let you know that, since the Pragma header is so tightly tied to the Cache-Control header, adding an extra option for it would not be useful. So, such an option is not planned for Add-Headers.

    However, what you can do is filter the headers just before they are sent to the client and remove any header you do not want. The headers are held in an array and, although it is currently easy to isolate the header in question, I plan to add a descriptive key to each array item, so it would be very easy to remove the Pragma header at that level. It may sound complicated, but it’s not.

    This is planned for the next release. I’ll provide all the necessary sample code to get this done.

    Kind Regards,
    George

    Plugin Author George Notaras

    (@gnotaras)

    @ssu1

    Also, one remark about the generation of the Expires header I’ve forgotten to write about earlier.

    By setting the add_expires_header to false, Add-Headers is instructed to stop generating the Expires header. But, please keep in mind that WordPress itself, another plugin, or the web server could add an Expires header to the response.

    If you disable the generation of the Expires header in Add-Headers, but you still see an Expires header in the web server response, then that Expires header has not been added by this plugin. Your best bet would be to check the web server configuration (main, virtualhost and htaccess if you are using apache) in such a case.

    BTW, what I had mentioned earlier has been implemented in 1.2.1 which will be out soon.

    To stop Add-Headers generate the Expires header, add this code to the functions.php file of the theme or in a custom plugin:

    function addh_custom_options ( $options ) {
        $options['add_expires_header'] = false;
        return $options;
    }
    add_filter( 'addh_options', 'addh_custom_options' );

    To remove the Pragma header or any other header (including the Expires header I mentioned above) generated by this plugin, use this code:

    function addh_filter_final_headers ( $headers ) {
        unset($headers['pragma']);
        //unset($headers['cache-control']);
        //unset($headers['expires']);
        //unset($headers['last-modified']);
        //unset($headers['etag']);
        return $headers;
    }
    add_filter( 'addh_headers', 'addh_filter_final_headers' );

    Hope this helps. Bare in mind, this is sample code. Some more checking might be required in some cases. Feel free to ask any questions.

    Marking the topic as resolved.

    George

    Plugin Author George Notaras

    (@gnotaras)

    Upcoming version 2.0.0 will have some changes in the key names of the $headers array, so the above code should be used like this:

    function addh_filter_final_headers ( $headers ) {
        unset($headers['Pragma']);
        //unset($headers['Cache-Control']);
        //unset($headers['Expires']);
        //unset($headers['Last-Modified']);
        //unset($headers['ETag']);
        return $headers;
    }
    add_filter( 'addh_headers', 'addh_filter_final_headers' );
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Feature Request: Option to disable PRAGMA & EXPIRE headers’ is closed to new replies.