mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-06 18:21:39 +09:00
Fix #2167 allow removing no-store and must-revalidate from Cache-Control headers
This commit is contained in:
parent
35dec01ab0
commit
15648d10d1
6 changed files with 29 additions and 1 deletions
|
|
@ -481,9 +481,11 @@ class Context
|
|||
*/
|
||||
public static function setCacheControl($ttl = 0, $public = true)
|
||||
{
|
||||
$cache_control_header = config('cache.cache_control') ?? 'must-revalidate, no-store, no-cache';
|
||||
|
||||
if($ttl == 0)
|
||||
{
|
||||
header('Cache-Control: ' . ($public ? '' : 'private, ') . 'must-revalidate, no-store, no-cache');
|
||||
header('Cache-Control: ' . ($public ? '' : 'private, ') . $cache_control_header);
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
|
||||
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ return array(
|
|||
'ttl' => 86400,
|
||||
'servers' => array(),
|
||||
'truncate_method' => 'delete',
|
||||
'cache_control' => 'must-revalidate, no-store, no-cache',
|
||||
),
|
||||
'ftp' => array(
|
||||
'host' => 'localhost',
|
||||
|
|
|
|||
|
|
@ -71,6 +71,7 @@ class Advanced extends Base
|
|||
Context::set('object_cache_dbnum', 1);
|
||||
}
|
||||
Context::set('cache_truncate_method', Config::get('cache.truncate_method'));
|
||||
Context::set('cache_control_header', array_map('trim', explode(',', Config::get('cache.cache_control') ?? 'must-revalidate, no-store, no-cache')));
|
||||
|
||||
// Thumbnail settings
|
||||
$oDocumentModel = getModel('document');
|
||||
|
|
@ -175,6 +176,16 @@ class Advanced extends Base
|
|||
Config::set('cache.truncate_method', $vars->cache_truncate_method);
|
||||
}
|
||||
|
||||
$cache_control = ['no-cache'];
|
||||
foreach (['no-cache', 'no-store', 'must-revalidate'] as $val)
|
||||
{
|
||||
if (isset($vars->cache_control_header) && in_array($val, $vars->cache_control_header))
|
||||
{
|
||||
$cache_control[] = $val;
|
||||
}
|
||||
}
|
||||
Config::set('cache.cache_control', implode(', ', array_reverse($cache_control)));
|
||||
|
||||
// Thumbnail settings
|
||||
$oDocumentModel = getModel('document');
|
||||
$document_config = $oDocumentModel->getDocumentConfig();
|
||||
|
|
|
|||
|
|
@ -194,6 +194,8 @@ $lang->cache_truncate_method = 'Cache Truncate Method';
|
|||
$lang->cache_truncate_method_delete = 'Delete cache folder itself';
|
||||
$lang->cache_truncate_method_empty = 'Delete content of cache folder';
|
||||
$lang->about_cache_truncate_method = 'It is faster and more reliable to delete the cache folder itself.<br />Choose the option to delete content only if the cache folder cannot be deleted, e.g. it is a mountpoint.';
|
||||
$lang->cache_control_header = 'Cache-Control header';
|
||||
$lang->about_cache_control_header = 'Select the Cache-Control header to apply to HTML pages that generally should not be cached.<br>Deselecting some of these options may help in certain circumstances, but at the cost of displaying outdated information.';
|
||||
$lang->msg_cache_handler_not_supported = 'Your server does not support the selected cache method, or Rhymix is unable to use the cache with the given settings.';
|
||||
$lang->msg_invalid_default_url = 'The default URL is invalid.';
|
||||
$lang->msg_default_url_ssl_inconsistent = 'In order to use SSL always, the default URL must also begin with https://';
|
||||
|
|
|
|||
|
|
@ -195,6 +195,8 @@ $lang->cache_truncate_method = '캐시 비우기 방법';
|
|||
$lang->cache_truncate_method_delete = '캐시 폴더를 삭제';
|
||||
$lang->cache_truncate_method_empty = '캐시 내용만 삭제';
|
||||
$lang->about_cache_truncate_method = '캐시 폴더를 삭제하는 방법이 더 빠르고 안정적입니다.<br />내용만 삭제하는 방법은 램디스크를 캐시 폴더로 사용하는 등 폴더 자체를 삭제해서는 안 되는 경우에만 선택하십시오.';
|
||||
$lang->cache_control_header = '캐시 컨트롤 헤더';
|
||||
$lang->about_cache_control_header = '브라우저 캐시를 적용하지 않을 일반 HTML 페이지에 적용할 Cache-Control 헤더 내용을 선택할 수 있습니다.<br>선택을 해제하면 뒤로가기 등 특정한 상황에서 성능이 개선될 수도 있지만, 오래된 정보가 노출되는 등 부작용이 발생할 수도 있습니다.';
|
||||
$lang->msg_cache_handler_not_supported = '선택하신 캐시 방식을 서버에서 지원하지 않거나, 주어진 정보로 캐시에 접속할 수 없습니다.';
|
||||
$lang->msg_invalid_default_url = '기본 URL이 올바르지 않습니다.';
|
||||
$lang->msg_default_url_ssl_inconsistent = 'SSL을 항상 사용하실 경우 기본 URL도 https://로 시작해야 합니다.';
|
||||
|
|
|
|||
|
|
@ -191,6 +191,16 @@
|
|||
<p class="x_help-block">{$lang->about_cache_truncate_method}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label">{$lang->cache_control_header}</label>
|
||||
<div class="x_controls">
|
||||
<label for="cache_control_header_no_cache" class="x_inline"><input type="checkbox" name="cache_control_header[]" id="cache_control_header_no_cache" value="no-cache" checked="checked"|cond="in_array('no-cache', $cache_control_header)" disabled="disabled" /> no-cache</label>
|
||||
<label for="cache_control_header_no_store" class="x_inline"><input type="checkbox" name="cache_control_header[]" id="cache_control_header_no_store" value="no-store" checked="checked"|cond="in_array('no-store', $cache_control_header)" /> no-store</label>
|
||||
<label for="cache_control_header_must_revalidate" class="x_inline"><input type="checkbox" name="cache_control_header[]" id="cache_control_header_must_revalidate" value="must-revalidate" checked="checked"|cond="in_array('must-revalidate', $cache_control_header)" /> must-revalidate</label>
|
||||
<br />
|
||||
<p class="x_help-block">{$lang->about_cache_control_header}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="x_control-group">
|
||||
<label class="x_control-label">{$lang->manager_layout}</label>
|
||||
<div class="x_controls">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue