如何为 smarty 运行 gzip
我想加快由 smarty 模板制作的页面的加载速度,我认为 gzip 是个好主意。 我看到此页面(此页面),但我不明白如何使用它!
- 这是最好的方法吗?
- 如何在smarty模板中激活gzip?
i want to speed up load pages maked by smarty template,i think gzip is good idea.
i see this page (this page) but i dont understand how can use this !
- is this best way?
- how can active gzip in smarty template?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Smarty(自版本 3.0 起)具有加载内部系统插件的新格式。
将 gzip 文件拖放到 /plugins 目录中(即,outputfilter.gzip.php。)
就在 $smarty->display 调用之前:
您不能再使用“load_filter”。
Smarty (since version 3.0) has a new format of loading the internal sys plugins.
Drop the gzip file in the /plugins dir (ie. outputfilter.gzip.php.)
And just before the $smarty->display call:
You can't use 'load_filter' anymore.
您需要查看 http://html5boilerplate.com/ 中的 .htaccess 文件。这就是您所需要的,将其放在 Web 服务器的顶级目录中,apache 就会解决 gzip 问题。
如果您已有 .htaccess 文件,则需要合并这两个文件。
上传 .htaccess 后,如果您想测试它是否正常工作,我最好的工具是 FireBug for FireFox,使用网络检查器并查看响应标头。作为后备尝试 http://www.whatsmyip.org/http_compression/ 但它需要该网站在线公开。
You will want to take a look at the .htaccess file from http://html5boilerplate.com/. It is all you need, put it at the top directory on your web server and apache takes care of the gzip problem.
If you have a .htaccess file already, you need to merge the two.
Once the .htaccess is uploaded and you want to test whether or not it is working, my best tool is FireBug for FireFox using the Net inspector and looking at the response headers. As a fallback try http://www.whatsmyip.org/http_compression/ it will however require the site to online and publicly available.