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. Jun 21 '18 at 12:52
  • @JeffreyvonGrumbkow how should I send plugin to you? Jun 21 '18 at 23:34
  • Upload it to wetransfer or something and paste the URL here :) Jun 22 '18 at 15:56
  • @JeffreyvonGrumbkow [link]: files.fm/u/f5a4xhv5 Jun 22 '18 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. Jun 26 '18 at 7:39
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' );

This site is temporarily in read only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .