Changeset 555


Ignore:
Timestamp:
Dec 15, 2015 10:29:47 PM (8 years ago)
Author:
anonymous
Message:

Further improvements to JS and CSS caching

Location:
trunk/lib
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/CSS.inc.php

    r554 r555  
    145145        }
    146146
     147        header('Content-Type: text/css; charset=' . $this->getParam('character_set'));
     148        header(sprintf('Last-Modified: %s GMT', gmdate('D, d M Y H:i:s', $latest_mtime), null));
    147149        if ($this->getParam('cache_enable')) {
    148             header(sprintf('Last-Modified: %s GMT', gmdate('D, d M Y H:i:s', $latest_mtime), null));
    149150            header(sprintf('Cache-Control: public, max-age=%s', $this->getParam('cache_seconds')));
     151            header(sprintf('Expires: %s GMT', gmdate('D, d M Y H:i:s', $latest_mtime + $this->getParam('cache_seconds'))));
    150152            header('Pragma: public');
     153            header('Vary: Accept-Encoding');
    151154        } else {
     155            header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
    152156            header('Expires: -1');
    153157            header('Pragma: no-cache');
    154             header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
    155158        }
    156         header('Content-Type: text/css; charset=' . $this->getParam('character_set'));
    157159    }
    158160
  • trunk/lib/JS.inc.php

    r554 r555  
    145145        }
    146146
     147        header('Content-Type: application/javascript; charset=' . $this->getParam('character_set'));
     148        header(sprintf('Last-Modified: %s GMT', gmdate('D, d M Y H:i:s', $latest_mtime), null));
    147149        if ($this->getParam('cache_enable')) {
    148             header(sprintf('Last-Modified: %s GMT', gmdate('D, d M Y H:i:s', $latest_mtime), null));
    149150            header(sprintf('Cache-Control: private, max-age=%s', $this->getParam('cache_seconds')));
     151            header(sprintf('Expires: %s GMT', gmdate('D, d M Y H:i:s', $latest_mtime + $this->getParam('cache_seconds'))));
    150152            header('Pragma: private');
     153            header('Vary: Accept-Encoding');
    151154        } else {
     155            header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
    152156            header('Expires: -1');
    153157            header('Pragma: no-cache');
    154             header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
    155158        }
    156         header('Content-Type: application/javascript; charset=' . $this->getParam('character_set'));
     159
    157160    }
    158161
Note: See TracChangeset for help on using the changeset viewer.