mage/fpc 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

mage/fpc

Composer 安装命令:

composer require mage/fpc

包简介

README 文档

README

this extension requires Redis Magento Builtin cache enabled and php_redis php extension installed. The phpredis extension provides a native PHP API for communicating with the Redis key-value store.

Tested With: 2.4.7 Magento version

#RHEL / CentOS
#Installation of the php-pecl-redis package, from the EPEL repository:

yum install php-pecl-redis

Cloud Flare CDN FPC Cache Microservice Layer

Works great together with this Cloud Flare Worker FPC cache Layer: https://github.com/Genaker/CloudFlare_FPC_Worker

The Idea behind this Magento 2 FPC performance extension

When I developed a Shopware 6-based website I noticed fast sub 1ms performance of the FPC cache. I checked the code and it amazed me. It is simple and made the right PHP way! Symfony Http cache! You don't need Varnish to run your FPC cache fast. You need just fast code without reusing the Magento 2 junk core framework.

Installation

Nginx

fastcgi_param PHP_VALUE "auto_prepend_file=/var/www/html/magento/app/code/Mage/FPC/FPC.php";

/var/www/html/magento/app/ shuld be changet to your magento path

or

add it as a first line to app/bootstrap.php or pub/index.php

Also if you are using composer to install this stuff your path will be something like : ../vendor/mage/fpc/src/Mage/FPC.php

Installation into the app folder is preferable. It is not a useless library. It is a part of your business to keep your site FAST.

require "../app/code/Mage/FPC.php";

Also, this extension will work without this additional interaction (just install and forget) but it will be slower because it will load all Magento 2 via autoloader.

or do next:

composer require mage/fpc
bin/magento setup:upgrade
bin/magento fpc:deploy

Performance

FPC generation time is 0.000481128 second.

Test

Test Magento Headers:

image
In this case, we need install php-redis extension: ``` sudo apt-get install php-redis ```

NodeJS implementation

npm install ioredis node-cache dotenv
or nmp install
node FPC.js

Replace Nginx:

location / {
    try_files $uri $uri/ /index.php$is_args$args;
}

With:

# Try Node.js first, fallback to static files, then PHP
location / {
    # Try serving from Node.js first
    proxy_pass http://127.0.0.1:3001;
    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

    # If Node.js fails, fallback to static files and then PHP
    error_page 406 502 504 = @fallback;
}

# Fallback to Static Files or PHP if Node.js Fails
location @fallback {
    try_files $uri $uri/ /index.php$is_args$args;
}

Understanding Stale-While-Revalidate

The stale-while-revalidate caching strategy is designed to minimize latency by serving cached content immediately, even if it’s slightly outdated, while simultaneously updating the cache with fresh data in the background. This approach ensures that users receive a quick response and the cache remains up-to-date without blocking the main request flow.

Performance Test :

FPC-TIME:0.88ms
FPC-TIME:0.99ms
FPC-TIME:0.79ms
FPC-TIME:0.98ms
FPC-TIME:1.51ms
FPC-TIME:1.08ms
FPC-TIME:0.98ms

With in-memory cache:

FPC-TIME:0.25ms
FPC-TIME:0.22ms
FPC-TIME:0.23ms
FPC-TIME:0.62ms
FPC-TIME:0.24ms
FPC-TIME:0.46ms
FPC-TIME:0.42ms
FPC-TIME:0.29ms
FPC-TIME:0.28ms
FPC-TIME:/->0.14ms
FPC-TIME:/->0.15ms
FPC-TIME:/->0.14ms
FPC-TIME:/->0.15ms
FPC-TIME:0.25ms
FPC-TIME:0.22ms
FPC-TIME:0.20ms

Magento GO FPC (Full Page Cache)

A high-performance caching solution for Magento built with Go, featuring multi-layer caching, goroutines for concurrent processing, and Redis integration.<\br>

Features:

  • Multi-layer caching (Local memory + Redis)
  • Concurrent request handling with goroutines
  • Rate limiting (250 req/s with 500 burst)
  • Stale cache management
  • Profiling and monitoring
  • Gzip compression support
  • Static file caching
  • Debug mode with detailed logging

Running the Server

# Build the binary
go build -o fpc FPC.go

# Run the server
./fpc

# Or run directly
go run FPC.go

mage/fpc 适用场景与选型建议

mage/fpc 是一款 基于 Go 开发的 Composer 扩展包,目前已累计 284 次下载、GitHub Stars 达 88, 最近一次更新时间为 2022 年 02 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 284
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 88
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 88
  • Watchers: 7
  • Forks: 19
  • 开发语言: Go

其他信息

  • 授权协议: proprietary
  • 更新时间: 2022-02-08