`

drupal7+varnish: varnish总是miss的原因

    博客分类:
  • web
 
阅读更多



最近发现不知什么原因,匿名用户访问的页面都返回varnish miss,这样造成后台的访问压力非常大。经过几天的debug,总算把问题解决了。下面是问题的总结。

[How to isolate the issue]

If you see the normal anonymous page, it’s HTTP Header always show ‘Cache-Control: public, max-age=xxx’, and can see ‘X-Cache:Hit’.

 

For the problem page, header will be ‘Cache-Control: no-cache,must-revalidate,post-check=0,pre-check=0’, also first access can see ‘Set-Cookie: SESSxxx=xxx’.

 

If drupal7 session cookie exists, following request will always miss cache.

 

[Reason]

For varnish, it depends on apache’s response to determine whether a request will be cached. If apache response header contains ‘Cache-Control: public max-age=xxx’, it will be cached for max-age. If header contains ‘Cache-Control: no-cache’, it will always pass the request to apache.

 

For anonymous user, drupal7 will not start session by default. This is for performance consideration. If session exists, drupal7 will always return no cache header and drop a session cookie.

 

But if any data put into $_SESSION, the user session will be started. Dive into the code, in common.inc, function drupal_page_footer will call session.inc’s function drupal_session_commit(). It will check if any data in $_SESSION then call drupal_session_start() to start a session.

If some errors in template, the error string will put into $_SESSION, then drupal7 will start the session.

分享到:
评论

相关推荐

    Drupal7宝典+Drupal开发指南+Using Drupal

    本资源包包含了三本书籍,可以帮助你深入理解和掌握Drupal7的各个方面: 1. **Drupal7宝典**: 这本书全面覆盖了Drupal7的基础知识,包括安装与配置、模块开发、主题设计、网站性能优化等。它将帮助你了解Drupal7...

    drupal-varnish:已归档

    Drupal Docker容器映像的清漆Docker映像 :red_exclamation_mark: 为了获得更好的可靠性,我们发布了带有带有稳定性标签( wodby/drupal-varnish:4-XXX )的图像。 我们强烈建议仅使用带有稳定性标签的图像。 概述: ...

    用drupal+php+jquery+mysql建的电子商务网站

    7. robots.txt:搜索引擎爬虫的指南,指示哪些页面可以被抓取,哪些应该被禁止。 8. profiles:包含了 Drupal 站点配置信息,如默认主题、预设模块等。 9. scripts:可能包含了一些辅助脚本,用于特定的部署或维护...

    vagrant-ansible-LAMP-nginx-varnish-playbook:使用Packer,Ansible和Vagrant的LAMP + Nginx + Varnish与Drupal和Mysql

    使用Packer,Ansible和Vagrant的LAMP + Nginx + Varnish与Drupal和Mysql Packer脚本,用于生成AMI,Docker容器,Droplet,VM Box等。 然后根据需要将其后处理到无业游民的盒子中。 进一步与vagrantfile链接以进行...

    Drupal+7+Multi+Sites+Configuration

    Drupal 7 是 Drupal 的一个版本,其多站点配置功能允许用户从一个 Drupal 7 的实例运行多个网站。这在需要管理多个网站的大型组织或希望为客户提供网站托管服务的网络托管提供商中非常有用。 在进行 Drupal 7 多...

    一本关于Drupal 7的英文书 Beginning Drupal 7

    ### 关于《Beginning Drupal 7》的知识点梳理 #### 一、书籍基本信息 - **书名**:《Beginning Drupal 7》 - **作者**:Todd Tomlinson - **出版社**:Apress - **出版年份**:2010年 - **ISBN-13(纸质版)**:...

    docker-drupal8-php7:Drupal 8 + PHP7

    码头工人-drupal8-php7 Drupal 8 + PHP7

    apache+mysql+php+drupal安装手册

    介绍了apache2.2.14+mysql5.1.3+php5.2.9+phpmyadmin3.7.1+drupal6.19 的全部安装过程

    plupload-drupal6:plupload 与 Drupal 6 文件域集成的原型实现。 对于 Drupal 7 + 8,请参阅 https

    plupload-drupal6 plupload 与 Drupal 6 文件域集成的原型实现。 对于 Drupal 7 + 8,请参阅 要求:cck 6.x-2.9、filefield 6.x-3.13 和 jquery_update 6.x-2.x-dev 配置为使用 jquery 1.7。

    样板-drupal7-高级:Drupal 7样板项目,具有由Docksal支持的高级配置

    码头动力的Drupal 7安装这是预先配置为与Docksal一起使用的示例香草Drupal 7安装。 特征: 香草Drupal 7 fin init示例Drupal多站点示例Behat设置示例和示例测试设定说明步骤#1:码头环境设置这是一次性设置-如果您...

    drupal7安装说明

    Drupal 7 是一个流行的开源内容管理系统,用于构建各种类型的网站。本教程将详细介绍如何在本地环境中安装 Drupal 7,特别是针对使用 Apache2、PHP5 和 MySQL5 的集成环境,如 AppServ。 首先,确保你已经安装了...

    drupal 7 中文版

    Drupal 7 中文版是全球知名的开源内容管理系统(CMS)Drupal的一个特定版本,它特别针对中文用户进行了优化,包括提供完整的中文语言包。这个版本,7.38,是Drupal 7系列的一个稳定更新,旨在增强用户体验,提高系统...

    drupal7-docker:在Docker容器中具有完整Drupal 7安装的文件结构

    Drupal 7泊坞窗 一个文件结构,可在Docker容器中完整安装Drupal 7。 特征 安装了拉丝机 已安装作曲家 最后安装的Drupal 7开发版本 不同Docker容器中的Apache和MySQL 如何使用 有4个bash文件可以非常简单地执行常见...

    drupal7权威指南

    ### Drupal7权威指南知识点概述 #### 一、Drupal7概览与优势 - **Drupal7简介**:Drupal7是一款开源的内容管理系统(CMS),被广泛应用于搭建各种类型的网站,包括个人博客、企业门户、社区平台等。它以其强大的...

    varnish:Lullabot 的默认 Varnish VCL 配置

    Lullabot 是一家专注于 Drupal 开发的公司,他们为自己的项目开发了一套默认的 Varnish VCL(Varnish Configuration Language)配置,以优化 Web 应用的性能。 VCL 是 Varnish 的核心组成部分,是一种专门用于定义...

    drupal8-vagrant:简单的Drupal 8开发环境

    5. **Drupal**:这个项目专注于Drupal 8,但也提及了Drupal 7,说明可能也支持旧版本的迁移或兼容。 6. **php7**:Drupal 8需要PHP 7或更高版本,表明此环境支持最新的PHP标准。 7. **Development Environment**:...

Global site tag (gtag.js) - Google Analytics