summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndy Staudacher <andy.st@gmail.com>2009-06-29 22:10:10 -0700
committerAndy Staudacher <andy.st@gmail.com>2009-06-29 22:10:10 -0700
commitb0bc99a81f933a6bfa6cca2d3a34102de1eee7ba (patch)
tree2b10b04af16b119ac0c2cff50bdf6232fcba3d61
parentd4738ce4844d39d55fec7f149c6aff5c061c0a38 (diff)
parentc9e8ff8fcb4c42948c8272ae367adda83957c101 (diff)
Merge branch 'master' of git@github.com:gallery/gallery3
-rw-r--r--.htaccess14
-rw-r--r--modules/gallery/controllers/combined.php33
-rw-r--r--modules/gallery/libraries/Gallery_View.php1
3 files changed, 34 insertions, 14 deletions
diff --git a/.htaccess b/.htaccess
index 46dbb2f4..f1996eed 100644
--- a/.htaccess
+++ b/.htaccess
@@ -10,11 +10,25 @@
</IfModule>
# Try to disable the parts of mod_security that interfere with the Flash uploader
+#
<IfModule mod_security.c>
SecFilterEngine Off
SecFilterScanPOST Off
</IfModule>
+# Improve performance by uncommenting this block. It tells the
+# browser that your images don't change very often so it won't keep
+# asking for them. If you get an error after uncommenting this, make
+# sure you specify "AuthConfig Indexes" in your Apache config file.
+#
+# <IfModule mod_expires.c>
+# ExpiresActive On
+# # Cache all files for a month after access (A).
+# ExpiresDefault A2678400
+# # Do not cache dynamically generated pages.
+# ExpiresByType text/html A1
+# </IfModule>
+
# You can use mod_rewrite to enable short urls in Gallery 3 (which
# gets rid of the "index.php" from your urls). To do this, you must
# uncomment the block below that starts with <IfModule> and ends with
diff --git a/modules/gallery/controllers/combined.php b/modules/gallery/controllers/combined.php
index 9df74638..925d052d 100644
--- a/modules/gallery/controllers/combined.php
+++ b/modules/gallery/controllers/combined.php
@@ -40,9 +40,14 @@ class Combined_Controller extends Controller {
* @param string the key (typically an md5 sum)
*/
private function _emit($type, $key) {
+ $input = Input::instance();
+
// Our data is immutable, so if they already have a copy then it needs no updating.
- if (!empty($_SERVER["HTTP_IF_MODIFIED_SINCE"])) {
+ if ($input->server("HTTP_IF_MODIFIED_SINCE")) {
header('HTTP/1.0 304 Not Modified');
+ header("Expires: Tue, 19 Jan 2038 00:00:00 GMT");
+ header("Cache-Control: max-age=2678400");
+ header('Pragma: public');
return;
}
@@ -54,26 +59,28 @@ class Combined_Controller extends Controller {
Session::abort_save();
$cache = Cache::instance();
- if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false ) {
- $content = $cache->get("{$key}_gz");
- }
-
- if (!$content) {
+ $use_gzip = function_exists("gzencode") &&
+ (strpos($input->server("HTTP_ACCEPT_ENCODING"), "gzip") !== false);
+ if ($use_gzip && $content = $cache->get("{$key}_gz")) {
+ header("Content-Encoding: gzip");
+ } else {
+ // Fall back to non-gzipped if we have to
$content = $cache->get($key);
}
- if (!$content) {
+ if (empty($content)) {
Kohana::show_404();
}
- if (strpos($_SERVER["HTTP_ACCEPT_ENCODING"], "gzip") !== false) {
- header("Content-Encoding: gzip");
- header("Cache-Control: public");
- }
-
// $type is either 'javascript' or 'css'
- header("Content-Type: text/$type; charset=UTF-8");
+ if ($type == "javascript") {
+ header("Content-Type: application/javascript; charset=UTF-8");
+ } else {
+ header("Content-Type: text/css; charset=UTF-8");
+ }
header("Expires: Tue, 19 Jan 2038 00:00:00 GMT");
+ header("Cache-Control: max-age=2678400");
+ header('Pragma: public');
header("Last-Modified: " . gmdate("D, d M Y H:i:s T", time()));
Kohana::close_buffers(false);
diff --git a/modules/gallery/libraries/Gallery_View.php b/modules/gallery/libraries/Gallery_View.php
index 40d78f94..32d79ac3 100644
--- a/modules/gallery/libraries/Gallery_View.php
+++ b/modules/gallery/libraries/Gallery_View.php
@@ -90,7 +90,6 @@ class Gallery_View_Core extends View {
$cache = Cache::instance();
$contents = $cache->get($key);
- $contents = "";
if (empty($contents)) {
$contents = "";
foreach ($links as $link) {