定制 flowpack/fullpagecache 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

flowpack/fullpagecache

Composer 安装命令:

composer require flowpack/fullpagecache

包简介

Cache full Neos page responses

README 文档

README

This package is meant to cache full HTTP responses for super fast delivery time. It currently works with Neos but a plan is there to provide the functionality for Flow as well.

It works by checking if a page is fully cachable and in that case caching the whole HTTP response and delivering it immediately. So this won't have much effect on websites with uncached elements on every page. Also POST requests and requests with query arguments are excluded from caching, as well as requests that set cookies. So if you don't see a difference after installing, these are things to look out for.

Settings

Following settings are available to influence the behavior:

Flowpack:
  FullPageCache:
    # enable full page caching
    enabled: true

    # the maximum public cache control header sent
    # set to 0 if you do not want to send public CacheControl headers
    maxPublicCacheTime: 86400

    # requests have to fulfill certain conditions for beeing cached
    request:
      # !!! Only the http methods "GET" and "HEAD" are supported !!!

      # a request will only qualify for caching if it contains no cookieParams that
      # are not ignored.
      cookieParams:
        # ignored cookie params exclude cookies that are handled by the frontend
        # and are not relevant for the backend. A usecase would be gdpr consent cookies
        # if they are only used on the client side
        ignore: []

      # a request will only qualify for caching if it only contains queryParams that
      # are allowed or ignored. All other arguments will prevent caching.
      queryParams:
        # allowed params become part of the cache identifier, use this for
        # arguments that modify the reponse but still allow caching like pagination
        allow: []

        # ignored arguments are not part of the cache identifier but do not
        # prevent caching either. Use this for arguments that are meaningless for
        # the backend like utm_campaign
        ignore: []

You can also move the cache backend to something faster if available, to improve performance even more.

How it works

The package defines two http middlewares:

  • RequestCacheMiddleware: If a request is cacheable the cache is asked first and only if no response is found the request is passed down the middleware chain. The cache lifetime and tags are determined from the X-FullPageCache-Enabled, X-FullPageCache-Lifetime and X-FullPageCache-Tags that are set by upstream middlewares or controllers. Additionally the middleware adds ETag and Cache-Control Headers taking the lifetime and setting maxPublicCacheTime into account.

  • FusionAutoconfigurationMiddleware: Connects to the fusion cache and extracts tags plus the allowed lifetime which is then stored in the response headers X-FullPageCache-Enabled, X-FullPageCache-Lifetime and X-FullPageCache-Tags. This component is only active if the header X-FullPageCache-EnableFusionAutoconfiguration is present in the response which is set automatically for Neos.Neos:Page.

Custom controllers that want to control the caching behavior directly can set the headers X-FullPageCache-Enabled, X-FullPageCache-Lifetime and X-FullPageCache-Tags directly while fusion based controllers can enable the autoconfiguration by setting the header X-FullPageCache-EnableFusionAutoconfiguration.

Warning

This package is still fairly new, if you install it, make sure to check really well if your page still works. Especially things like Forms and plugins. Ideally those pages should work but just not be faster unlike pure content pages. Still this was tested in limited scenarios so far, so make sure you tested properly before bringing this to production. It has no effect on the content itself, so deinstalling it will bring you back to the state you had before.

flowpack/fullpagecache 适用场景与选型建议

flowpack/fullpagecache 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 86.87k 次下载、GitHub Stars 达 14, 最近一次更新时间为 2019 年 11 月 12 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 flowpack/fullpagecache 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 flowpack/fullpagecache 我们能提供哪些服务?
定制开发 / 二次开发

基于 flowpack/fullpagecache 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 86.87k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 14
  • 点击次数: 17
  • 依赖项目数: 1
  • 推荐数: 1

GitHub 信息

  • Stars: 14
  • Watchers: 12
  • Forks: 10
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-11-12