phpmyadmin.css.php is not cached on the client, i.e. the whole stylesheet is fetched for every pageview. This puts unnecessary load on the webserver and makes use of phpMyAdmin slower (depending on connection speed).
In older versions, the file IS cached, but since phpMyAdmin started using session it isn't anymore, because PHP sends a lot of anti-caching headers when using the built-in session support ($_SESSION).
This patch adds an Expires HTTP header to the stylesheet, so that it is always cached for one hour. If the session parameters are changed, this is tracked in the Config class, and the modification time is added to the query string of phpmyadmin.css.php, so that the file is always fetched again when the session variables hav changed.
The cache period (one hour) could be arbitrarily long. As long as the stylesheet isn't requested every few seconds, it is fine.
Perhaps the modification time mechanism added to the Config class can be used for other purposes.
Patch
Logged In: YES
user_id=210714
Originator: NO
Merged, with a little change in header_meta_style.inc.php, you were using a short tag. Thanks.
Logged In: YES
user_id=1383652
Originator: NO
ok,
not a big deal, but if i change the font-size
the left frame is not updated to the new value.
Logged In: YES
user_id=32013
Originator: YES
File Added: catch-2.patch
Fix for right frame and other remaining places
Logged In: YES
user_id=1383652
Originator: NO
well, that 2nd patch fixes the navi css problem, thx
Logged In: YES
user_id=210714
Originator: NO
Thanks I'll merge this new patch.
Logged In: YES
user_id=210714
Originator: NO
Merged, thanks to Christian Schmidt and to Juergen for testing.
Logged In: YES
user_id=192186
Originator: NO
Isn't caching too aggressive? When I switch theme, browser is still using old CSS.
Logged In: YES
user_id=192186
Originator: NO
Maybe adding of theme name to URL would help this...
Logged In: YES
user_id=32013
Originator: YES
I suggest that the config object takes care of storing the selected theme instead of having the Theme_Manager setting cookies directly. I'll try and have a look at this later this week.
Logged In: YES
user_id=1383652
Originator: NO
>Isn't caching too aggressive? When I switch theme,
>browser is still using old CSS.
i can confirm this behaviour on demo but *not* on my local svn version (FF, w2k, apache 2.2.2, php 5.2).
on demo: when you change the fontsize afterwards the new css takes effect.
there are oviously different methods used in both "option onchange" functions.
maybe this is a clue where to look.
Logged In: YES
user_id=210714
Originator: NO
I can confirm the theme problem on my local svn version (FF 2).
Logged In: YES
user_id=32013
Originator: YES
The problem is that the selected theme is stored as a cookie instead of in the session like the fontsize. The "right" way to solve this is to add a "Vary: Cookie" header to phpmyadmin.css.php, but IE (including IE6 and IE7) has limited support for Vary and doesn't cache the file at all, so unfortunately this isn't the best solution.
I have noticed that libraries/common.inc.php mentions that some calls to PHP_setCookie should be replaced with PMA_Config->set(). If it has been decided that these settings should be handled by PMA_Config, then Theme_Manager should probably also use it. However, this is a somewhat complicated project, and I am not sure I am the right to solve that given that I am fairly new to the PMA project.
A quick fix for the immediate problem is to set a dummy session variable, i.e. add the following to Theme_Manager::setThemeCookie():
$_SESSION['PMA_Config']->set('theme-update', $this->theme->id);
Another solution is to call $_SESSION['PMA_Config']->set() from within PMA_setCookie().
A third solution is to add the theme name to the querystring of phpmyadmin.css.php.
Any thoughts on this?
Logged In: YES
user_id=210714
Originator: NO
Thanks Christian, fix applied to Theme_Manager.