- 浏览: 146771 次
- 性别:
- 来自: 大连
-
文章分类
- 全部博客 (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.
相关推荐
内容概要:本文详细介绍了基于TMS320F系列芯片的C2000串口读写方案及其编程器——FlashPro2000的功能特点和支持的接口模式。文中不仅涵盖了硬件连接的具体步骤,还提供了代码实例来展示Flash擦除操作,并对比了JTAG和SCI-BOOT两种模式的优缺点。此外,针对不同型号的C2000系列芯片,给出了详细的适配指导以及避免烧录过程中可能出现的问题的方法。 适合人群:从事DSP开发的技术人员,尤其是对TI公司C2000系列芯片有一定了解并希望深入了解其编程和烧录细节的人群。 使用场景及目标:适用于实验室环境下的程序调试阶段,以及生产线上的批量烧录任务。主要目的是帮助开发者选择合适的编程工具和技术手段,提高工作效率,减少因误操作导致设备损坏的风险。 其他说明:文中提供的代码片段和命令行指令可以直接用于实际项目中,同时附带了一些实用技巧,如防止芯片变砖的小贴士和自动化重试脚本,有助于解决常见的烧录难题。
汉字字库存储芯片扩展实验 # 汉字字库存储芯片扩展实验 ## 实验目的 1. 了解汉字字库的存储原理和结构 2. 掌握存储芯片扩展技术 3. 学习如何通过硬件扩展实现大容量汉字字库存储 ## 实验原理 ### 汉字字库存储基础 - 汉字通常采用点阵方式存储(如16×16、24×24、32×32点阵) - 每个汉字需要占用32字节(16×16)到128字节(32×32)不等的存储空间 - 国标GB2312-80包含6763个汉字,需要较大存储容量 ### 存储芯片扩展方法 1. **位扩展**:增加数据总线宽度 2. **字扩展**:增加存储单元数量 3. **混合扩展**:同时进行位扩展和字扩展 ## 实验设备 - 单片机开发板(如STC89C52) - 存储芯片(如27C256、29C040等) - 逻辑门电路芯片(如74HC138、74HC373等) - 示波器、万用表等测试设备 - 连接线若干 ## 实验步骤 ### 1. 单芯片汉字存储实验 1. 连接27C256 EPROM芯片到单片机系统 2. 将16×16点阵汉字字库写入芯片 3. 编写程序读取并显示汉字 ### 2. 存储芯片字扩展实验 1. 使用地址译码器(如74HC138)扩展多片27C256 2. 将完整GB2312字库分布到各芯片中 3. 编写程序实现跨芯片汉字读取 ### 3. 存储芯片位扩展实验 1. 连接两片27C256实现16位数据总线扩展 2. 优化字库存储结构,提高读取速度 3. 测试并比较扩展前后的性能差异 ## 实验代码示例(单片机部分) ```c #include <reg52.h> #include <intrins.h> // 定义存储芯片控制引脚 sbit CE = P2^7; // 片选 sbit OE = P2^6; // 输出使能 sbit
测控装备干扰源快速侦测系统设计研究.pdf
嵌入式八股文面试题库资料知识宝典-【开发】嵌入式开源项目&库&资料.zip
嵌入式八股文面试题库资料知识宝典-百度2022年嵌入式面试题.zip
少儿编程scratch项目源代码文件案例素材-空间站.zip
基于关联规则的商业银行个性化产品推荐.pdf
嵌入式八股文面试题库资料知识宝典-Linux基础使用.zip
内容概要:本文详细介绍了利用MATLAB进行轴棱锥生成贝塞尔高斯光束及环形光束光强图像的仿真研究。首先阐述了实验的背景与目标,强调了MATLAB在光学和计算科学领域的广泛应用。接着,具体描述了实验的方法与步骤,包括材料准备、仿真过程中的参数设定和光束生成代码编写。最后,对实验结果进行了深入分析,展示了贝塞尔高斯光束和环形光束的光强分布特点,验证了其光学性能的预期表现。文章还对未来的研究方向和技术改进提出了展望。 适合人群:从事光学、物理学及相关领域研究的专业人士,特别是对光束生成和光学性能分析感兴趣的科研工作者。 使用场景及目标:适用于需要进行光束生成和性能分析的实验室环境,旨在帮助研究人员更好地理解和优化光束特性和传播行为。 其他说明:本文不仅提供了详细的实验方法和步骤,还附有丰富的实验结果和数据分析,为后续研究提供了宝贵的参考资料。
内容概要:本文探讨了三电平NPC型有源电力滤波器(APF)的模型预测控制(MPC)中存在的开关频率过高问题及其解决方案。传统MPC方法会导致极高的开关频率,增加了系统的能耗和热量。通过引入滞环控制模块,可以在不大幅牺牲性能的情况下有效降低开关频率。具体来说,滞环控制通过在价值函数计算后增加一个判断条件,对状态切换进行惩罚,从而减少不必要的开关动作。实验结果显示,开关频率从4392Hz降至3242Hz,降幅达26.2%,虽然电流总谐波畸变率(THD)略有上升,但仍符合国家标准。此外,文中还提出了动态调整滞环宽度的方法,以进一步优化不同负载条件下的表现。 适合人群:从事电力电子、电力系统控制领域的研究人员和技术人员,特别是关注APF和MPC技术的人群。 使用场景及目标:适用于需要优化APF系统开关频率的研究和工程项目,旨在提高系统效率并降低成本。目标是在不影响系统性能的前提下,显著降低开关频率,减少能量损失和热管理难度。 其他说明:文章不仅提供了理论分析,还包括具体的实现代码片段,有助于读者理解和实践。同时,强调了在实际应用中需要注意的问题,如中点电位漂移等。
内容概要:本文介绍了三维POD DMD程序在处理原网格数据方面的独特优势和技术细节。首先阐述了该程序能读取结构化和非结构化网格数据及其拓扑关系,在生成模态数据过程中保持原始网格形态而不需要进行网格插值操作。接着展示了简化版本的Python代码片段,揭示了读取网格数据和生成模态数据的核心逻辑。最后提到提供的辅助学习资料如代码、视频教程、Word教程和实例数据,帮助用户深入理解并掌握该程序的应用。 适合人群:从事计算流体力学领域的研究人员和技术爱好者,尤其是那些希望提高数据处理效率的人群。 使用场景及目标:适用于需要处理复杂网格数据的研究项目,旨在简化数据处理流程,提升工作效率,同时保持数据的原始特性。 其他说明:文中不仅提供了理论性的讲解,还有具体的代码示例和丰富的学习资源,使读者可以边学边练,快速上手。
融合双向路由注意力的多尺度X光违禁品检测.pdf
嵌入式八股文面试题库资料知识宝典-Linux_Shell基础使用.zip
嵌入式八股文面试题库资料知识宝典-联发科2021武汉嵌入式软件开发.zip
基于有限体积法Godunov格式的管道泄漏检测模型研究.pdf
嵌入式八股文面试题库资料知识宝典-ARM常见面试题目.zip
基于LWR问题的无证书全同态加密方案.pdf
嵌入式八股文面试题库资料知识宝典-符坤面试经验.zip
内容概要:本文详细探讨了三电平逆变器在带不平衡负载条件下的仿真研究。主要内容包括仿真环境的搭建、不同拓扑结构的选择(如T型、I型NPC和ANPC)、延时相消法(DSC)和双二阶广义积分器(DSOGI)的正负序分离控制策略、SVPWM或SPWM调制技术的应用、双闭环PI控制以及直流均压控制。文中通过具体的参数设置(交流电压220V,直流侧电压750V)进行了详细的仿真实验,并展示了各个控制策略的效果。最终,通过仿真实验验证了所提出方法的有效性,确保了交流侧三相电压波形的对称性和电流波形的自适应调节。 适合人群:从事电力电子、电机驱动、新能源发电等领域研究的技术人员和研究人员。 使用场景及目标:适用于需要理解和掌握三电平逆变器在复杂负载条件下控制策略的研究人员和技术人员。目标是提高对三电平逆变器及其控制策略的理解,优化实际应用中的性能。 其他说明:本文不仅提供了理论分析,还包含了具体的仿真步骤和代码实现,有助于读者更好地理解和应用相关技术。
内容概要:本文介绍了如何使用Matlab/Simulink软件构建一个14自由度的四轮驱动-四轮转向(4WID-4WIS)整车动力学模型。该模型涵盖了整车纵向、横向、横摆、车身俯仰、侧倾、垂向跳动及四轮旋转和垂向自由度等多个方面,旨在全面反映车辆在不同工况下的动态行为。文中详细描述了各子系统的建模方法,包括转向系统、整车系统、悬架系统、魔术轮胎pac2002、车轮系统和PI驾驶员模块。同时,提供了Simulink源码文件、建模说明文档及相关参考资料,便于用户理解和应用。 适用人群:主要面向汽车工程师、研究人员以及对汽车动力学和Simulink建模感兴趣的学习者。 使用场景及目标:①帮助用户深入了解车辆在各种工况下的动态行为;②为车辆控制策略的制定提供理论支持和技术手段;③作为学习和研究整车动力学建模的有效工具。 其他说明:该模型采用模块化建模方法,提高了模型的清晰度和可维护性,同时也提升了建模效率。