aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClaude <longneck@scratchbook.ch>2018-09-29 15:16:47 +0200
committerClaude <longneck@scratchbook.ch>2018-09-29 15:16:47 +0200
commit3fdf28338619b807ea5249d28c3775277369e60f (patch)
tree215ce31d83045df5c59042a5055f9d5340d2a04f
parent83f52c2f38220755ed6fd5efa38ee1f64b3e2ad1 (diff)
downloadstikked-fit-3fdf28338619b807ea5249d28c3775277369e60f.tar.gz
stikked-fit-3fdf28338619b807ea5249d28c3775277369e60f.tar.bz2
stikked-fit-3fdf28338619b807ea5249d28c3775277369e60f.zip
ability to set content expiration. fixes #457
-rw-r--r--htdocs/application/config/stikked.php.dist10
-rw-r--r--htdocs/application/controllers/Main.php17
2 files changed, 27 insertions, 0 deletions
diff --git a/htdocs/application/config/stikked.php.dist b/htdocs/application/config/stikked.php.dist
index c8779e9..4725dc4 100644
--- a/htdocs/application/config/stikked.php.dist
+++ b/htdocs/application/config/stikked.php.dist
@@ -91,6 +91,16 @@ $config['js_editor'] = ''; // codemirror, ace, ''
$config['combine_assets'] = false;
/**
+ * Content expiration
+ *
+ * Sets the "Expires:"-header to make use of browser-caching
+ * Format: http://php.net/manual/en/function.strtotime.php
+ * Examples: '+10 seconds', '+1 year', '-1 week'
+ *
+*/
+$config['content_expiration'] = '-1 week';
+
+/**
* Key for Cron
*
* The password required to run the cron job */
diff --git a/htdocs/application/controllers/Main.php b/htdocs/application/controllers/Main.php
index 49d676e..94d48cf 100644
--- a/htdocs/application/controllers/Main.php
+++ b/htdocs/application/controllers/Main.php
@@ -442,6 +442,7 @@ class Main extends CI_Controller
if (!$this->input->post('submit'))
{
$data = $this->_form_prep();
+ $this->content_expiration(config_item('content_expiration'));
$this->load->view('home', $data);
}
else
@@ -555,6 +556,7 @@ class Main extends CI_Controller
$this->load->helper('text');
$data['raw'] = character_limiter($data['raw'], 500);
}
+ $this->content_expiration(config_item('content_expiration'));
$this->load->view('view/raw', $data);
}
else
@@ -593,6 +595,7 @@ class Main extends CI_Controller
if ($check)
{
$data = $this->pastes->getPaste(3, true, $this->uri->segment(4) == 'diff');
+ $this->content_expiration(config_item('content_expiration'));
$this->load->view('view/embed', $data);
}
else
@@ -609,6 +612,7 @@ class Main extends CI_Controller
if ($check)
{
$data = $this->pastes->getPaste(3);
+ $this->content_expiration('+1 year');
$this->load->view('view/qr', $data);
}
}
@@ -697,6 +701,7 @@ class Main extends CI_Controller
{
$data['reply_form']['use_recaptcha'] = 0;
}
+ $this->content_expiration(config_item('content_expiration'));
$this->load->view('view/view', $data);
}
else
@@ -1018,4 +1023,16 @@ class Main extends CI_Controller
echo '';
}
}
+
+ function content_expiration($cache_time)
+ {
+ if(!$cache_time)
+ {
+ $cache_time = '-1 week';
+ }
+ $cache_expiration = strtotime($cache_time);
+ $this->output->set_header('Pragma: ', true);
+ $this->output->set_header('Cache-Control: ', true);
+ $this->output->set_header('Expires: ' . gmdate('D, d M Y H:i:s', $cache_expiration) . ' GMT', true);
+ }
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy