【问题标题】: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);
    

    【讨论】:

      猜你喜欢
      • 2018-01-27
      • 2012-10-01
      • 2012-11-01
      • 2015-03-28
      • 2015-11-24
      • 1970-01-01
      • 2016-12-10
      • 2016-04-02
      • 2011-07-02
      相关资源
      最近更新 更多