0

I'm currently using a plugin called 'Userpro' for user registration and login.

This plugin culprit is that it adds no-store, no-cache headers whenever activated.

I contacted plugin authors for the fix but no avail.

My question if anyone can help. Is there any way to stop this plugin from adding headers automatically.

I've tried the code below. It overrides the header but doesn't stop the plugin from adding its header

function varnish_safe_http_headers() {
    header( 'X-UA-Compatible: IE=edge,chrome=1' );
    session_cache_limiter('');
    header("Cache-Control: public, s-maxage=120");
  if( !session_id() )
  {
    session_start();
  }
}
add_action( 'send_headers', 'varnish_safe_http_headers' );

Thanks

6
  • It depends how the headers are added. If the plugin also uses add_action you can simply remove the action. The easiest way is to use Query Monitor plugin to see what actions are being added, so you can remove them. Otherwise you can send me the plugin (since its paid) and I can check the code for you to see if there's a way to remove the headers without changing the plugin files.
    – Jebble
    Commented Jun 21, 2018 at 12:52
  • @JeffreyvonGrumbkow how should I send plugin to you? Commented Jun 21, 2018 at 23:34
  • Upload it to wetransfer or something and paste the URL here :)
    – Jebble
    Commented Jun 22, 2018 at 15:56
  • @JeffreyvonGrumbkow [link]: files.fm/u/f5a4xhv5 Commented Jun 22, 2018 at 16:08
  • I've checked the entire plugin and it actually never sets any no-cache / no-store headers. All they do is check if they're set yes or no.
    – Jebble
    Commented Jun 26, 2018 at 7:39

1 Answer 1

0

Add this file to your plugin folder.

<?php
    /*
    Plugin Name: Remove cache headers
    Description: Remove Cache-Control and Pragram header
    Version: 0.1
    Author: Deluxe Themes
    */
    function varnish_safe_http_headers() {
    if( !session_id() )
    {
    session_start();
    }
    header_remove ('Cache-Control');
    header_remove ("Pragma");

    }
    add_action( 'send_headers', 'varnish_safe_http_headers' );

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.