Menu

#339 (ok 2.10.0) Allow client caching of phpmyadmin.css.php

closed-fixed
Interface (183)
1
2007-02-28
2006-12-08
No

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.

Discussion

  • Christian Schmidt

    Patch

     
  • Marc Delisle

    Marc Delisle - 2006-12-10
    • priority: 5 --> 1
    • summary: Allow client caching of phpmyadmin.css.php --> (ok 2.10.0) Allow client caching of phpmyadmin.css.php
    • assigned_to: nobody --> lem9
    • status: open --> open-accepted
     
  • Marc Delisle

    Marc Delisle - 2006-12-10

    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.

     
  • Jürgen Wind

    Jürgen Wind - 2006-12-16

    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.

     
  • Christian Schmidt

    Logged In: YES
    user_id=32013
    Originator: YES

    File Added: catch-2.patch

     
  • Christian Schmidt

    Fix for right frame and other remaining places

     
  • Jürgen Wind

    Jürgen Wind - 2006-12-17

    Logged In: YES
    user_id=1383652
    Originator: NO

    well, that 2nd patch fixes the navi css problem, thx

     
  • Marc Delisle

    Marc Delisle - 2006-12-19

    Logged In: YES
    user_id=210714
    Originator: NO

    Thanks I'll merge this new patch.

     
  • Marc Delisle

    Marc Delisle - 2006-12-19
    • priority: 1 --> 5
    • summary: (ok 2.10.0) Allow client caching of phpmyadmin.css.php --> Allow client caching of phpmyadmin.css.php
     
  • Marc Delisle

    Marc Delisle - 2006-12-21

    Logged In: YES
    user_id=210714
    Originator: NO

    Merged, thanks to Christian Schmidt and to Juergen for testing.

     
  • Marc Delisle

    Marc Delisle - 2006-12-21
    • priority: 5 --> 1
    • summary: Allow client caching of phpmyadmin.css.php --> (ok 2.10.0) Allow client caching of phpmyadmin.css.php
     
  • Michal Čihař

    Michal Čihař - 2007-01-03

    Logged In: YES
    user_id=192186
    Originator: NO

    Isn't caching too aggressive? When I switch theme, browser is still using old CSS.

     
  • Michal Čihař

    Michal Čihař - 2007-01-03

    Logged In: YES
    user_id=192186
    Originator: NO

    Maybe adding of theme name to URL would help this...

     
  • Christian Schmidt

    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.

     
  • Jürgen Wind

    Jürgen Wind - 2007-01-03

    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.

     
  • Marc Delisle

    Marc Delisle - 2007-01-03
    • priority: 1 --> 4
     
  • Marc Delisle

    Marc Delisle - 2007-01-03

    Logged In: YES
    user_id=210714
    Originator: NO

    I can confirm the theme problem on my local svn version (FF 2).

     
  • Christian Schmidt

    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?

     
  • Marc Delisle

    Marc Delisle - 2007-01-12
    • priority: 4 --> 1
    • status: open-accepted --> open-fixed
     
  • Marc Delisle

    Marc Delisle - 2007-01-12

    Logged In: YES
    user_id=210714
    Originator: NO

    Thanks Christian, fix applied to Theme_Manager.

     
  • Marc Delisle

    Marc Delisle - 2007-02-28
    • status: open-fixed --> closed-fixed