【问题标题】:if-modified-since request header drupal 7if-modified-since 请求标头 drupal 7
【发布时间】:2017-12-05 17:36:06
【问题描述】:
我想为 Drupal 7 中的所有请求添加“If-modified-since”标头。
然后我需要响应 304/200 状态代码依赖于 LastModiified 响应头。
我尝试通过hook_boot() 实现它。但是这段代码不起作用:
function custom_views_hooks_boot() {
//
}
我用x debag调试,结果发现函数里面的代码连运行都没有。
【问题讨论】:
标签:
php
drupal
header
drupal-7
【解决方案1】:
1 - 在 DRUPAL_ROOT/includes 中创建文件(例如:custom_bootstrap.inc)
2 - 编辑 DRUPAL_ROOT/index.php
require_once DRUPAL_ROOT . '/includes/custom_bootstrap.inc';
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
menu_execute_active_handler();
3 - 将你的东西放入 custom_bootstrap.inc
header('If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT');
4 - 如果您需要一些 drupal 数据库功能,可以选择包含 mini bootstrap:
require_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_DATABASE);