在一个拥有大量流量的新项目中,我们正在考虑如何构建我们的Symfony2应用程序以充分利用缓存,并准备在未来更具侵略性。我很想知道你的意见。如何使用ESI构建Symfony2应用程序?
比方说,用户请求一个页面的地方列表。这个页面有:
- list
- common data (title, author, description)
- user data (the user likes the list + other data)
- first 20 places
- common data (title, photo of each place)
- user data (the rates of the user for those places)
的HTML可能是这样的:
<html>...
<body>
<header>
...
<!-- Embed the top user menu -->
<esi:include src="http://example.com/profile/menu" />
...
</header>
<content>
...
common data of the list
...
<!-- Embed the common data of the first 20 places, the same for everyone -->
<esi:include src="http://example.com/lists/17/places" />
...
<!-- Embed the user data of the list (used in JS) -->
<esi:include src="http://example.com/lists/17/user" />
...
<!-- Embed the user data of the list of places (used in JS) -->
<esi:include src="http://example.com/lists/17/places/user" />
...
</content>
</body>
</html>
的HTML将在网关(Symfony的或清漆)进行缓存。大部分时间都会在网关上缓存地点列表。用户数据请求将被调用并且不被缓存(至少不是最初)。
问题:
- 你怎么看待这种结构?
- 如果用户是匿名的,我可以避免为用户数据制作esi-includes吗?另外,如果我有一个匿名用户的cookie?怎么样?
- 用户菜单的esi-include是否有意义?
- 或者我们应该忘记ESI并始终通过控制器(例如缓存公共数据的渲染视图)?
- 我们应该将请求用户数据的2个ESI请求移动到AJAX调用,而不是在服务器上等待吗?
- 如果我们需要快速完成这是一个很好的缩放方法吗?什么是最好的?
非常感谢!
非常感谢barius, 我们正在代替ESI Ajax中的用户数据请求。所以我同意你的看法。让我们看看它是如何发展的。 关键&乐趣部分将与避免使用PURGE。这是能够扩展的目标。 – fesja
分享它尝试后的方式 –