WinCache – Preliminary tests look REALLY good

Posted on 7th September 2009 by Nio in Cache, 程序人生 - Tags: ,

WinCache – Preliminary tests look REALLY good

Those of you who follow me on twitter know that recently, I tweeted that I had installed Microsoft’s new PHP Opcode Cache, WinCache on a test machine and didn’t see much difference in performance. I then later tweeted that it was probably due to my inexperience in managing II7 and not necessarily a failing of WinCache. In between those two posts, I received 2 messages from people working with Microsoft, the most helpful being from Ruslan Yakushev. If you recognize that name it’s because he writes a lot of good stuff over at iis.net including the getting started guide for WinCache.

Ruslan picked up on the tweet and wrote me a very nice “How can I help” email. It started a conversation that eventually let me to the problem I was having, but I’ve only just now had a chance to finish my rudimentary testing. I can now say that yes, it was my configuration that I had wrong and once I took Ruslan’s advice, I am seeing a tremendous improvement.

Optimize Parallel Downloads to Minimize Object Overhead

Posted on 19th July 2009 by Nio in Cache, 程序人生 - Tags: ,

Optimize Parallel Downloads to Minimize Object Overhead

Summary: With the average web page growing past 50 external objects, object overhead now dominates most web page delays. Increasing parallel downloads by using multiple hostnames can realize up to a 40% improvement in web page latency.

浏览器对于同一域名下的文件(图片、JS、CSS)加载是依次进行的,当一个页面中的这些外部对象太多的时候,这种加载延迟会给访问者造成很慢的感觉。通过使用多个域名,解析到同一个服务器,可以“欺骗”浏览器,使其同时对这些外部对象并行加载,从而加快客户端的加载速度。在这基础之上,还可以使用 CDN 进一步优化服务器端,使 B/S 加载速度平衡。

用 JSON 处理缓存

Posted on 11th November 2006 by Nio in AJAX, Cache, 程序人生

来自 IBM developerWorks 的《用 JSON 处理缓存》:

数据验证是每个企业 Web 应用程序中最富于挑战性、日新月异的部分。通常验证元数据会使 JavaScript 模块中混入服务器端代码。在本文中,您将了解如何在服务器代码的帮助下将元数据缓存在客户端的优秀方法,服务器代码将提供 JSON(JavaScript Object Notation)形式的字符串化元数据。这种方法还允许以类似 Ajax 的方式来处理多值和多组属性。

PHP & memcached

Posted on 6th April 2006 by Nio in Cache, 程序人生

总算完成了这篇文章--PHP & memcached,希望对同学们有用,另外,欢迎大家一起交流讨论 :)

关于 Cache(4)

Posted on 7th June 2005 by Nio in Cache, 程序人生

如何分离个人信息,缓存动态页面

肖理达 (KrazyNio AT hotmail.com), 2005.06.07, 转载请注明出处

一直想写一篇关于动态页面 cache 的文章,但每次“提笔”却又放弃,因为总是觉得准备得还不够充分。今天埋头写下,只是希望对自己的工作做一些笔录。

1、问题起源

我们经常会在一个动态页面中加入很多个人信息,以 CMS 首页为例,用户登录之前显示登录框,登录之后显示其用户名,并根据权限显示其可用模块的链接。由于每个用户登录之后,显示出来的动态信息都是不一样的,所以这部分无法进行 cache,我们将这部分信息定义为“[u]个人信息[/u]”,它的特性是根据登录用户进行动态改变。

现在问题来了,就是一个 CMS 的首页,访问者的登录概率并不是百分百的,应该说有一大部分人访问首页是没有登录的,这个时候的首页是一个公共的页面,没有任何个人信息,或者说这时候首页的任何动态信息都是可以转换成静态的,也就是说这部分是可 cache 的。

2、使用 JavaScript 分离个人信息

解决这个问题的方法有很多种,一种是将个人信息和其他信息进行分离,如在 CMS 首页中加入一个外部的 JavaScript 文件,而这个文件的内容实际上是由 PHP 动态生成的。CMS 首页 index.php 代码片段:

<script language="JavaScript" src="/js/personal.php"></script>
....
<script language="JavaScript">
document.write(sUser);
document.write(sLinks);
</script>

personal.php 代码片段:

<?php
session_start();
header("Cache-Control: no-store, no-cache, must-revalidate");
?>
sUser = "<?php echo $_SESSION['USER']; ?>";
sLinks = "<?php echo addslashes($_SESSION['LINKS']); ?>";

这种方法比较适合个人信息较少,易于集中显示的情况。通过 JavaScript 外挂代码实现个人信息分离之后,personal.php 是永不 cache 的,这样也就可以放心地对 CMS 首页进行 cache 了,具体的 cache 方法可采用 304 HTTP 头与 Cache_Lite 相结合的方式,这在后边有详细代码示例。

(more…)