Support » Plugin: WP Super Cache » https vs http cache confusion – with solution

  • Problem: Various core wordpres functions call is_ssl() when generating uri’s – in particular all of the get_theme related functions do this. If a site is available on https and http then pages may be generated unpredictably with https:// or http:// internal links to stylesheets etc. A similar thing happens when behind amazon load balancers that send SSL traffic to port 80 except in this case the uri is always http: even when it should be https

    a page generated with http:// that gets cached and served to an a https: viewer will break due to non secure elements.

    Solution add to functions.php in your theme (or better still fold into wp_supercache)

    //Make URI's protocol agnostic
    add_filter( 'theme_root_uri', 'my_theme_root_uri');
     * Make uri's protocol agniostic
    function my_theme_root_uri($uri) {
    	return preg_replace("@^https?:@i","",$uri);

    This will make all uri’s returned by theme_root_uri() protocol agnostic allowing the page to work in either http or https (example “” becomes “//”).

    See for more on uri’s without a protocol part.

  • The topic ‘https vs http cache confusion – with solution’ is closed to new replies.