简体   繁体   English

Magento整页缓存和清漆

[英]Magento full page caching with varnish

I have been looking at full page caching in magento and something does not make sense with this and how dynamic blocks are sent. 我一直在看magento中的全页缓存,这和动态块的发送方式并没有什么意义。

For blocks containing dynamic data, the application still needs to be bootstrapped and the layout needs to be built in order to generate the blocks for example basket content, recently viewed etc 对于包含动态数据的块,仍然需要启动应用程序,并需要构建布局以生成块,例如购物篮内容,最近查看的内容等。

The server is now doing more work. 服务器现在正在做更多的工作。

Is this correct and if so how to get around this 这是正确的,如果可以的话,如何解决这个问题

my 2 cents: 我的2美分:

It depends on how you are doing your FPC... 这取决于您如何进行FPC ...

"proxy cache" “代理缓存”

If you are using some other caching frontend/proxy like nginx or varnish or [insert one here] then it REALLY decreases the load as you do: 如果您正在使用其他一些缓存前端/代理,例如nginx或varnish或[在此处插入一个],那么它实际上会减少负载:

  1. one request to get the "frame" of the page which after its cached doesn't even touch php or magento or mysql, just serves a static file. 一个获取页面“框架”的请求,该页面在缓存后甚至不触摸php或magento或mysql,仅提供一个静态文件。 So once its cached it doesn't need to bootstrap the app or load and parse any layout/config/system xml. 因此,一旦将其缓存,就无需重新引导应用程序或加载并解析任何布局/配置/系统xml。
  2. the second request is to get the dynamic content and is MUCH lighter. 第二个请求是获取动态内容,并且要轻得多。 yes it still has to use the config/layout/system xml but that should already be cached AND it doesn't have to create/process that many blocks depending on the dynamic needs. 是的,它仍然必须使用config / layout / system xml,但是应该已经将其缓存,并且不必根据动态需求创建/处理那么多的块。

also depending on what you need you could store information in cookies to be used by js after the page loads and not do the second request, again depends on how dynamic and sensitive that dynamic information is. 还取决于您需要什么,您可以将信息存储在页面加载后由js使用的cookie中,而不执行第二个请求,这再次取决于动态信息的动态性和敏感性。

So a request flow would be: 因此,请求流将是:

  1. Request -> nginx/varnish/etc(super fast) -> response ... 请求-> nginx / varnish / etc(超快)->响应...
  2. ajax request -> Magento for dynamic content (lighter processing then if doing the whole page) -> response -> js replace elements. ajax请求-> Magento以获取动态内容(如果处理整个页面,则进行更轻松的处理)->响应-> js替换元素。

Yes you do pay for the extra round trip, but you do get things to instantly load for the customer and while the ajax request is being processed the browser could be pulling images/css/other js from the server which is nice. 是的,您确实需要支付额外的往返费用,但确实可以为客户立即加载东西,并且在处理ajax请求时,浏览器可能会从服务器提取图像/ css /其他js,这很好。

"Magento FPC" “ Magento FPC”

Honestly I don't know how the enterprise edition does it (just haven't read the code) but before most (not all) things are processed there is a section that you can attach a cache processor. 老实说,我不知道企业版是如何做到的(只是没有阅读代码),但是在处理大多数(不是全部)事物之前,有一个部分可以附加一个高速缓存处理器。 In that environment the application has already been bootstrapped and some of the configuration loaded, so you could actually pull the FPC from the cache and then replace the place holders their with the specific information and send that out in just one request. 在那种环境中,应用程序已经被引导并加载了一些配置,因此您实际上可以从缓存中提取FPC,然后用特定信息替换其占位符,然后仅在一个请求中将其发送出去。

Again request flow: 再次请求流程:

Request -> Magento (before routing etc) -> punch holes -> response. 请求-> Magento(在布线之前)->打孔->响应。

So things don't start loading until the dynamic content is there, but you don't have the extra round trip. 因此,只有在动态内容存在之前,事情才开始加载,但是您没有多余的往返路程。


Conculsion: Conculsion:

As far as which one is the best, well that just depends on your needs and setup. 至于哪一个是最好的,那完全取决于您的需求和设置。 These are just two of the different setups I've seen and in my testing either method out performs having no FPC at all. 这些只是我所见过的两种不同设置,在我的测试中,两种方法都完全没有FPC。

HTH HTH

Not sure if I understand your question right but Magento and your server will do less work as it will only generate and deliver the hole punched, dynamic blocks which you define by XML. 不确定我是否理解您的问题,但是Magento和您的服务器将减少工作量,因为它只会生成并提供由XML定义的打孔动态块。 The rest of the page is static html delivered by varnish which does not even pass these requests on to magento. 页面的其余部分是由清漆提供的静态html,它甚至不会将这些请求传递给magento。

Take a look at this chart from Fabrizio Branca's Blog: 从Fabrizio Branca的博客中查看以下图表:

在此处输入图片说明

yes the second request hits the server. 是的,第二个请求命中了服务器。 it also loads the layout on line 30. this means that certain handles will loaded - default, customer_logged_out(or in) and the call controller (am i missing something?). 它还会在第30行加载布局。这意味着将加载某些句柄-默认,customer_logged_out(或in)和调用控制器(我缺少什么吗?)。 in this blog http://www.fabrizio-branca.de/make-your-magento-store-fly-using-varnish.html it's suggested you add your place holder to the default handle. 在此博客http://www.fabrizio-branca.de/make-your-magento-store-fly-using-varnish.html中 ,建议您将占位符添加到默认句柄。 the unsetChild method allows you to still load the block by name in the call controller. unsetChild方法允许您仍按名称在调用控制器中加载块。 the reason for this is described in some of alan storms blogs and (i think) a module of his deals with some of the problems regarding removed as opposed to unset blocks. 其原因在一些alan风暴博客中有所描述,并且(我认为)他的交易模块处理了与已删除块(而非未设置块)有关的一些问题。 cache invalidation isn't really handled by this module. 此模块并未真正处理缓存失效。 maybe you should view this post magento open source full page cache 也许您应该查看此帖子magento开源完整页面缓存

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Magento中的Full Page catch(FPC)和Magento内置缓存之间的区别 - Difference between Full Page catch(FPC) and Magento inbuilt caching in Magento Magento EE 1.9的缓存:我们应该使用整页缓存(带打孔)和/或“经典”块缓存吗? - Cache for Magento EE 1.9: Should we use full page caching (with hole punching) and/or “classical” block caching? Magento 2 清漆不缓存,每次都提供新的 cookie - Magento 2 varnish not caching, delivers new cookie each time 什么是全页缓存 - What is full page caching 如何使用清漆页面缓存在magento上启用geoip - How to Enable geoip on magento with varnish page cache 清漆(松节油):在Magento中冲洗前重新加载页面 - Varnish (Turpentine): Reload page before flushing in Magento Magento全页缓存 - Magento full page cache 为什么Magento对产品保存中的整页缓存失效实际上使页面没有被缓存以及刷新做什么,因为它没有被缓存 - Why Does Magento Invalidation of Full Page Caching on Product save actually make a page not cached and what does refresh do since it is not cached 产品评论显示产品页面信息以及使用Varnish,APC和块缓存的页面缓存 - Product Reviews showing product page information with page caching using Varnish, APC, and Block Caching 带有memcached的magento整页缓存 - magento full page cache with memcached
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM