mirror of
https://github.com/claudehohl/Stikked.git
synced 2025-04-25 20:41:20 -05:00
ability to set content expiration. fixes #457
This commit is contained in:
parent
83f52c2f38
commit
3fdf283386
@ -90,6 +90,16 @@ $config['js_editor'] = ''; // codemirror, ace, ''
|
|||||||
*/
|
*/
|
||||||
$config['combine_assets'] = false;
|
$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
|
* Key for Cron
|
||||||
*
|
*
|
||||||
|
@ -442,6 +442,7 @@ class Main extends CI_Controller
|
|||||||
if (!$this->input->post('submit'))
|
if (!$this->input->post('submit'))
|
||||||
{
|
{
|
||||||
$data = $this->_form_prep();
|
$data = $this->_form_prep();
|
||||||
|
$this->content_expiration(config_item('content_expiration'));
|
||||||
$this->load->view('home', $data);
|
$this->load->view('home', $data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -555,6 +556,7 @@ class Main extends CI_Controller
|
|||||||
$this->load->helper('text');
|
$this->load->helper('text');
|
||||||
$data['raw'] = character_limiter($data['raw'], 500);
|
$data['raw'] = character_limiter($data['raw'], 500);
|
||||||
}
|
}
|
||||||
|
$this->content_expiration(config_item('content_expiration'));
|
||||||
$this->load->view('view/raw', $data);
|
$this->load->view('view/raw', $data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -593,6 +595,7 @@ class Main extends CI_Controller
|
|||||||
if ($check)
|
if ($check)
|
||||||
{
|
{
|
||||||
$data = $this->pastes->getPaste(3, true, $this->uri->segment(4) == 'diff');
|
$data = $this->pastes->getPaste(3, true, $this->uri->segment(4) == 'diff');
|
||||||
|
$this->content_expiration(config_item('content_expiration'));
|
||||||
$this->load->view('view/embed', $data);
|
$this->load->view('view/embed', $data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -609,6 +612,7 @@ class Main extends CI_Controller
|
|||||||
if ($check)
|
if ($check)
|
||||||
{
|
{
|
||||||
$data = $this->pastes->getPaste(3);
|
$data = $this->pastes->getPaste(3);
|
||||||
|
$this->content_expiration('+1 year');
|
||||||
$this->load->view('view/qr', $data);
|
$this->load->view('view/qr', $data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -697,6 +701,7 @@ class Main extends CI_Controller
|
|||||||
{
|
{
|
||||||
$data['reply_form']['use_recaptcha'] = 0;
|
$data['reply_form']['use_recaptcha'] = 0;
|
||||||
}
|
}
|
||||||
|
$this->content_expiration(config_item('content_expiration'));
|
||||||
$this->load->view('view/view', $data);
|
$this->load->view('view/view', $data);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -1018,4 +1023,16 @@ class Main extends CI_Controller
|
|||||||
echo '';
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user