Subject: plugin_getheadercode cache issue

Posted on: 13/07/10 04:38am
By: ::Ben

Hi,

As in others plugins I'm using this function to add css and js to paypal plugin
PHP Formatted Code
function plugin_getheadercode_paypal()
{
        global $_CONF, $_PAY_CONF;

        $retval = '<link rel="stylesheet" href="' . $_CONF['site_url'] . '/paypal/css/paypal.css?ver=115" type="text/css" media="screen"' . XHTML . '>' . LB;
        $retval .= '<link rel="stylesheet" href="' . $_PAY_CONF['site_url'] . '/css/jcart.css?ver=115" type="text/css" media="screen"' . XHTML . '>' . LB;
        $retval .= '<script type="text/javascript" src="' . $_PAY_CONF['site_url'] . '/js/jcart-javascript.php"></script>' . LB;
       
        if(!defined('JQUERY')){
        $retval .= '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>'. LB;
                $retval .= '<script>
    if(jQueryNoConflict == undefined){
    jQuery.noConflict();
    var jQueryNoConflict = true;
    }
</script>'
. LB;

        define('JQUERY', 'true');
    }

        return $retval;
}
 


but don't know why, css files are reloaded with every page and increase the page load time.

My question is, why these files are not cached like other css files from plugins such as Polls or Links?

::Ben

Re: plugin_getheadercode cache issue

Posted on: 13/07/10 09:01am
By: Laugh

Ever since Suprsidr released his excellent Twitter plugin I had wanted to devise away to minimize loading of all the css and javascript files not needed for the page being currently viewed.

For example, the only thing that uses the Twitter plugin on one of my sites is the about us page and that is the only thing that uses jquery. It seems like a waste of resources to me by Geeklog of having jquery loaded for every single page (let alone it's css file).

This problem was one of those things I had wanted to look into but haven't had the time yet.

Re: plugin_getheadercode cache issue

Posted on: 13/07/10 09:29am
By: mystral-kk

Hi Ben,

How about changing

PHP Formatted Code
$retval = '<link rel="stylesheet" href="'  . $_CONF['site_url'] . '/paypal/css/paypal.css?ver=115" type="text/css" media="screen"' . XHTML . '>'  . LB;


to

PHP Formatted Code
$retval = '<link rel="stylesheet" href="'  . $_CONF['site_url'] . '/paypal/css/paypal.css" type="text/css" media="screen"' . XHTML . '>'  . LB;


If you add a query string to a URL, it is treated as a dynamic content , even if it is just a static CSS file. So, try removing the "?ver=115".

Re: plugin_getheadercode cache issue

Posted on: 13/07/10 11:21am
By: ::Ben

There is surely something else to do because removing the parameter ver=115 do not increase speed loading. Even a blanck css do not improve it. The only way I founded is to disable the css Cry

PHP Formatted Code
       
//$retval = '<link rel="stylesheet" href="' . $_CONF['site_url'] . '/paypal/css/paypal.css" type="text/css" media="screen"' . XHTML . '>' . LB;
//$retval       .= '<link rel="stylesheet" href="' . $_PAY_CONF['site_url'] . '/css/jcart.css" type="text/css" media="screen"' . XHTML . '>' . LB;


With css enable, loading time is about 10-20 seconds. Without, css loading time is 0,6 seconds :banghead:

Edit: Very strange, seems to be a browser issue. FireFox 3.6.6

Geeklog - Forum
https://www.geeklog.net/forum/viewtopic.php?showtopic=90737