- 浏览: 142534 次
- 性别:
- 来自: 大连
文章分类
- 全部博客 (135)
- Liferay (12)
- Alfresco (12)
- SIP (1)
- MFTV (7)
- Server (1)
- JVM (1)
- AR (1)
- Agile (1)
- DirectX (2)
- OTP (1)
- Windows (7)
- Electronic (1)
- Wowza (1)
- Documentum (1)
- CMIS (1)
- MCUMediaServer (2)
- Linux (1)
- LBS (1)
- Product Lifecycle Management (1)
- Robot (1)
- XBMC (4)
- Andriod (2)
- Boxee (2)
- Graphic (1)
- GPU (1)
- Openmeeting (2)
- Conference (2)
- GitHub (1)
- iOS (1)
- 越狱 (1)
- OpenELEC (2)
- WIFI (1)
- Big Blue Button (3)
- Sakai (1)
- Redmine (1)
- 联盟营销 (1)
- OpenSplash (1)
- MONO (1)
- HTML5 (1)
- AirPlay (1)
- PHPMotion (1)
- Java (1)
- Maven (1)
- Proxy (1)
- JDK (1)
- Mac (1)
- REST (1)
- JSON (1)
- IT互联网 (1)
最新评论
http://www.delishost.com/2012/01/tuning-your-phpmotion-theme-for-performance/
Tuning your PHPmotion theme for performance
Nothing is worse then having to wait for a website to load and speed is even more important when your website has huge competitors such as Youtube and Dailymotion. Here we’ll take you through the steps to making your PHPmotion website load faster.
Note: These changes are based on the default theme, but should be applicable to custom themes with a few minor adjustments. Tests are measured on the home page, but will improve the entire site.
Scores are measured with the excellent YSlow! plugin for Firefox and Chrome .
The Test Case: phpmotionperformance.delishost.com
- Default PHPmotion V3.5 installation
- Some uploaded content to fill the site.
- Total page size: 465KB
- YSlow! Rating: C
- Page loaded in 6.40s
Warning: Always keep copies and backups of any files you modify!
Step 1: Host it close-by.
The closer your website is to your visitors the better, latency is reduced meaning files are transferred faster as the delay between connecting to the server and actually receiving the file is reduced.
If your main visitors are in the USA, then choosing a server there is an obvious choice. The same goes for hosting in Europe, having your site hosted with the correct host can make a noticeable difference to your end users. We offer fast, reliable hosting in European datacentres .
Step 2: Optimize your javascript and CSS files
To speed a site up we need to minimize the amount of bytes that are actually transferred from the server to the visitor’s browser. To do so we can compress all the javascript and CSS files that aren’t currently optimized.
Useful online tools for compressing files include:
- Online YUI Compressor (Javascript & CSS)
- Google Closure Compiler Service (Javascript only)
- CSS Compressor (CSS only)
This is a fairly simple step, simply search through your site for javascript and css files. The main places to look include:
- javascripts/
- css/
- themes/yourthemes/css/
Now upload these files one by one to the appropriate site from the above links. Make sure you’re not trying to compress an already compressed file. You can check this by opening the file, if everything looks like a solid block or a single line of text then it is already compressed.
Download their optimized versions and replace the file on the website.
Remember to keep a backup of each file and test the site functions after each change. As compressing can occasionally break Javascript functions so parts of your site will appear to stop working.
Step 3: Using DEFLATE to compress content
DEFLATE is an excellent way to reduce the amount of content that is sent to the browser. It works by compressing non binary files and sending the compressed versions to the visitor. Their browser then uncompresses and loads the content.
Enabling DEFLATE is pretty simple and definitely worth it. Open your .htaccess file and paste the following:
-
# DEFLATE
-
<IfModule mod_deflate.c>
-
AddOutputFilterByType DEFLATE application/x-javascript application/javascript text/javascript text/html text/plain text/css text/xml
-
</IfModule>
-
# End DEFLATE
Now upload your new .htaccess file and clear your browser cache (otherwise YSlow! may incorrectly report that it isn’t working). The total page size (no other changes) is now 218KB (53% savings! )
Step 4: Building a CDN
We’ll now concentrate on setting up a basic CDN. Many browsers limit parallel HTTP requests to two by domain. The default home page for our test site has 40 components which can only be downloaded 2 by 2. Setting up CDNs will allow us to multiple the maximum number of parallel requests and thus noticeably speed up the entire website.
In the following examples replace example.com
with your website domain name and /phpmotionpath/
with the path to your PHPmotion installation.
Here I will walk you through how to create the following:
- theme.example.com for theme stylesheets (themes/yourtheme/css/)
- css.example.com for non theme related stylesheets (css/)
- js.example.com for javascript files (js/)
- thumbs.example.com for video thumbnails (uploads/thumbs/)
You will be able to take this further if you wish, but these should already help load times on your website quite a bit.
To continue you will need a code editor that is capable of doing a search/replace across files otherwise you will spend a lot of time going through the files.
To make updates to CDN names easier in the future I have created a
PHP file which will hold all CDN names in an array for easy re-use in
the templates. Copy and save the following code into addons/dh-cdn.php
.
-
<?php
-
/**
-
* @author Ben Newman http://www.delishost.com
-
*
-
* This file simply holds variables for the different cdn names you can use in
-
* your themes. It allows you to add/modify CDNs without having to go through all
-
* your templates.
-
*
-
* You can access these through in the templates like so:
-
* [var.asset_cdn.theme]
-
*/
-
$asset_cdn = array(
-
'theme' => 'http://theme.example.com ', // To load theme assets
-
'cdn' => 'http://cdn.example.com ', // Mirrors the normal PHPmotion path
-
'js' => 'http://js.example.com ', // Loads the javascript files
-
'videothumbs' => 'http://thumbs.example.com ', // Loads thumbs from uploads/thumbs/
-
);
Upload this file to your server after making sure to enter the correct addresses for each one. Then open classes/config.inc.php
and add the following on a new line before ?>
.
-
include installation_paths().'/addons/dh-cdn.php';
Theme CSS CDN
Create a subdomain called theme.example.com
that points to /phpmotionpath/themes/yourtheme
. Once this is done you can test it is working by trying to load http://theme.example.com/css/main.css
in your browser. If it shows everything is correct then you can continue.
Note: You will need to update this if you switch themes in the future.
Editing themes/yourtheme/templates/main_1.htm
– search for the following strings:
-
[var.base_url]/themes/[var.user_theme]
And replace with:
-
[var.asset_cdn.theme]
Default CDN
The following CDN will point directly to the same directory as your
PHPmotion installation. This allows us to load any PHPmotion files over
the CDN. Create a subdomain cdn.example.com
that points to /phpmotionpath/
.
You will now be able to load any assets you like by simply replacing
the base url with this CDN one. Most strings that need editing are in themes/yourtheme/templates/main_1.htm
.
-
<link href="css/rating_style.css" rel="stylesheet" type="text/css" media="all">
-
<link href="css/thickbox.css" rel="stylesheet" type="text/css" media="screen">
-
<link href="greybox/gb_styles.css" rel="stylesheet" type="text/css" media="all">
-
<link href="javascripts/jquery.jcarousel.css" rel="stylesheet" type="text/css" media="all">
Becomes:
-
<link href="[var.asset_cdn.cdn]/css/rating_style.css" rel="stylesheet" type="text/css" media="all">
-
<link href="[var.asset_cdn.cdn]/css/thickbox.css" rel="stylesheet" type="text/css" media="screen">
-
<link href="[var.asset_cdn.cdn]/greybox/gb_styles.css" rel="stylesheet" type="text/css" media="all">
-
<link href="javascripts/jquery.jcarousel.css" rel="stylesheet" type="text/css" media="all">
Leave the javascripts/
one as we’ll use the js CDN for this one.
Javascript CDN
Create a subdomain js.example.com
that points to /phpmotionpath/javascripts/
.
This will allow you to load most of the javascript files. Using your
search/replace function use these two to setup the js cdn.
- Search: “javascripts/
- Replace with: “[var.asset_cdn.js]/
And:
- Search: “[var.base_url]/javascripts/
- Replace with: “[var.asset_cdn.js]/
Video thumbs CDN
Create a subdomain thumbs.example.com
that points to /phpmotionpath/uploads/thumbs/
. We’ll now be able to load all the video thumbs over this CDN.
Search for this string in your template files: "uploads/thumbs/"
and also "[var.base_url]/uploads/thumbs/
Replace with: "[var.asset_cdn.videothumbs]/
Step 5: Expires
The mod_expires Apache module allows you to set how long certain elements should stay cached in a visitors browser. This is a great way to speed up your website as browsers will know not to bother requesting certain content until it has expired.
You have to be careful when using this as changes you make to any
cached content will be ignored. You can get around this by appending ?v=1
to the end of your elements and updating the number each time you make a
change to that element. The browser will then think that it is a new
item and will re-download it.
We’ll set up some basic Expires rules in the /phpmotionpath/.htaccess
file.
-
# Expires
-
<IfModule mod_expires.c>
-
<FilesMatch "\.(gif|png|jpe?g|js|css|ico|swf)$">
-
ExpiresActive On
-
ExpiresDefault "access plus 1 week"
-
</FilesMatch>
-
</IfModule>
-
# End Expires
As you can probably tell from the above example your browser will
know to cache the files one week after their first access. It is a good
idea to only set this up once you’ve finished any theme changes to your
website otherwise you will have to append ?v=X
to all your assets to force them to be flushed from your browser cache.
Step 6: Advanced Optimisations
There are many other ways to improve load performance, but they require more work and knowledge of coding and server management. Here are a few things that you can look into to further optimize performance.
Image sprites
Image sprites are images (usually small theme images) that are grouped together into a single image file then used within the layout with css backgrounds, changing the background-position to display the right image in the right place. If your theme uses a lot of background images this is a fairly simple way to reduce http requests – providing you have a solid knowledge of CSS that is.
Proxy Cache
If you have a VPS or dedicated server you can setup a proxy cache server which will create and cache pages as they are accessed to majorly improve performance as your PHP files won’t even be accessed. This would require some configuration to avoid pages becoming stale and out of date.
Conclusion
Here is the final result after applying the above steps to the same page quite an improvement don’t you agree?
- Total page size: 217KB
- YSlow! Rating: A
- Page loaded in 4.43s
- Handles more parallel HTTP requests for assets
- Decreases bandwidth usage
- Caches assets in the browser with the mod_expires
Page load time has been shortened by a few seconds (the gain will vary depending on the page). Bandwidth usage will be reduced and thanks to caching less http requests mean less server traffic. Caching is also improved which means that repeat visits and any other pages loaded will be much faster.
I hope you found this post useful. If you did please be kind enough to share it. Feel free to leave any questions or suggestions you might have in the comments below.
相关推荐
WebSocket是一种在客户端和服务器之间建立长连接的协议,它允许双方进行全双工通信,即数据可以在两个方向上同时传输,极大地提高了实时性。在若依框架中集成WebSocket,可以为用户带来更流畅、即时的交互体验,尤其适用于需要实时更新数据的应用场景,如聊天室、股票交易、在线游戏等。
适用于练习各种服务部署和自己玩哈哈哈
ppt翻页不方便?我的程序完美解决触摸屏翻页功能! 屏幕两边置顶显示窗口,通过按下键盘↑↓键翻页,同时添加标注、橡皮、清屏功能,可以一键放映或退出放映 程序解说:https://blog.csdn.net/weixin_69784410/article/details/145038617
一个支持Modbus RTU和Modbus TCP报文解析,且能处理主站和从站两个方向的数据,并解析bool型、整数、浮点数等多种数据类型的工具,对于开发人员和运维人员来说是非常有帮助的。下面是一个概述和简要指南,帮助你了解如何开发或使用这样的工具。 支持的协议: Modbus RTU(串行通信) Modbus TCP(以太网通信) 报文解析: 主站发送和接收的报文 从站发送和接收的报文 数据类型解析: bool型(位) 整数(如16位、32位等) 浮点数(如32位IEEE 754浮点数) 用户界面: 图形用户界面(GUI),便于操作 可视化展示报文结构 原始报文和解析后数据的对比显示
44e82cfa75fa0244b3037221d2eb830d.zip
内容概要 本资源提供了一个完整的 Flappy Bird 游戏开发项目,并结合强化学习算法(Q-Learning)实现了一个自动玩 Flappy Bird 的 AI。项目包括以下内容: 游戏开发:基于 Pygame 的 Flappy Bird 游戏实现,包含小鸟、管道、背景、音效等元素。 强化学习算法:使用 Q-Learning 算法训练 AI,使其能够自动玩 Flappy Bird。 代码与资源:完整的 Python 代码、游戏图片、音效资源。 适用人群 游戏开发爱好者:对 Pygame 游戏开发感兴趣的开发者。 强化学习初学者:希望学习并实践 Q-Learning 算法的学生或开发者。 AI 爱好者:对游戏 AI 实现感兴趣的开发者。 使用场景及目标 学习 Pygame 游戏开发:通过本项目,可以学习如何使用 Pygame 开发一个简单的 2D 游戏。 实践强化学习算法:通过实现 Q-Learning 算法,理解强化学习的基本原理和应用。 训练游戏 AI:通过训练 AI,使其能够自动玩 Flappy Bird,并不断提升其表现。
GEC6818 交叉编译curl
关于做好2025届本科毕业设计(论文)工作的通知 各学院(系):我校2025届本科生毕业设计(论文)工作即将开始,根据《长安大学本科毕业论文(设计)工作管理办法(试行)》(长大教[2023]19号)(以下简称《管理办法》),为确保毕业设计(论文)质量,现将相关准备工作安排如下:一、组织工作1.组织领导。毕业设计(论文)工作是高校人才培养质量的重要环节,各学院(系)要切实加强对毕业设计(论文)工作的领导,成立专门领导小组或安排专人检查、管理毕业设计(论文)工作。认真执行“管理办法”,鼓励学生真题真做或通过科技竞赛、创新训练和创新性实验完成毕业设计(论文)工作。2.指导教师。毕业设计(论文)指导教师须按照“管理办法”中“指导教师资格与要求”规定遴选,由具有中级及以上职称的教师或工程技术人员担任。3.学生要求。学院对参加毕业设计(论文)的学生需按“管理办法”中“学生资格及要求”进行资格审核。4.师生比要求。为确保毕业设计(论文)的质量,充分发挥指导教师作用,每名指导教师所带毕业设计(论文)学生一般不得超过8人,首次指导的教师指导学生数不得超过3人。2024年校级抽检不合格的毕业设计(论文)指
鸢尾花数据集的特征变换是指对原始数据集中的特征进行一系列的处理和转换,以适应机器学习模型的输入要求。该数据集原本包含四个特征:萼片长度、萼片宽度、花瓣长度和花瓣宽度,这些特征都是数值型的,且以厘米为单位。然而,在实际应用中,原始特征可能无法满足模型的特定需求,因此需要进行特征变换。特征变换可以包括数据规范化、标准化、归一化等操作,旨在消除不同特征之间的量纲差异,提高模型的收敛速度和性能。通过特征变换,可以使数据更加适合机器学习算法的处理,从而提高模型的准确性和稳定性。 在鸢尾花数据集中,特征变换还可以涉及特征选择、特征提取或构造等高级操作。特征选择是根据相关性和重要性筛选出最有价值的特征,以减少模型的复杂度并提高泛化能力。特征提取则是通过统计分析、降维技术(如PCA)等方式生成新的特征,这些新特征能够更全面地反映数据的内在结构和信息。特征构造则是通过特征交叉、组合等方式生成新的特征,以增加模型的表达能力。这些高级的特征变换操作可以进一步提升机器学习模型的性能,使其能够更好地处理复杂的分类任务。在鸢尾花数据集的案例中,虽然原始特征已经足够描述样本,但在实际应用中,特征变
STM32 Foc开源算法,包括观测器和Foc method STM32F0系列FOC 源代码, 有单电阻采样和三电阻采样两种代码。 都是ST很经典算法,代码学习,无感算法观测器是开源代码,Foc method也是开源,不是库。
广州大学人工智能原理实验(三)代码包
ArcEngine二次开发的专题图自动生成系统(含源码+说明文档+设计报告等全部资料).zip [资源说明] 1、该项目是团队成员近期最新开发,代码完整,资料齐全,含设计文档等 2、上传的项目源码经过严格测试,功能完善且能正常运行,请放心下载使用! 3、本项目适合计算机相关专业(人工智能、通信工程、自动化、电子信息、物联网等)的高校学生、教师、科研工作者、行业从业者下载使用,可借鉴学习,也可直接作为毕业设计、课程设计、作业、项目初期立项演示等,也适合小白学习进阶,遇到问题不懂就问,欢迎交流。 4、如果基础还行,可以在此代码基础上进行修改,以实现其他功能,也可直接用于毕设、课设、作业等。 5、不懂配置和运行,可远程教学 欢迎下载,学习使用!
基于java的足球社区管理系统设计与实现.docx