SlideShare uma empresa Scribd logo
1 de 13
Harder, Better, Faster, Stronger
How compression, reduction, and
expiration can improve your site.
Harder, Better, Faster, Stronger
• Intro: Steven Souder’s 14 Rules (circa 2007)
• Tools
• Reducing HTTP requests
• Caching
• Minifying
• GZIP-ing
• Expires Headers
Agenda
Harder, Better, Faster, Stronger
• Make Fewer HTTP Requests
• Use a Content Delivery
Network
• Add an Expires Header
• Gzip Components
• Put Stylesheets at the Top
• Put Scripts at the Bottom
• Avoid CSS Expressions
• Make JavaScript and CSS
External
• Reduce DNS Lookups
• Minify JavaScript
• Avoid Redirects
• Remove Duplicate Scripts
• Configure ETags
• Make AJAX Cacheable
Steven Souder’s 14 Rules
http://stevesouders.com/hpws/rules.php
Harder, Better, Faster, Stronger
• YSLOW: Browser Add-in (Chrome, Firefox)
• Note: autorun affects your PHP Sessions
• http://tools.pingdom.com
• https://developers.google.com/speed/pagespeed/
Tools
Harder, Better, Faster, Stronger
• CSS Sprites
• http://csssprites.com/
• http://css-sprit.es/
• Mind size limits for mobile browser caching
• Combine scripts and stylesheets
• If not using Etags turn ‘em off in httpd.conf:
Header unset Etag
FileETag None
Reducing HTTP Requests
Harder, Better, Faster, Stronger
Server side
•Distributed: Memcached
•Opcode caching: Xcache, APC
Client side
•Cache headers
Caching
Harder, Better, Faster, Stronger
Javascript & CSS:
• remove extra chars, comments & whitespace
• reduce size for first page load
There are many online compressors:
• www.cssdrive.com
There are also local compressors:
• YUI compressor
• LESS/SASS tools (SimpLESS, WinLESS, etc.) will minify
resultant CSS.
Minification
Harder, Better, Faster, Stronger
1) Install if not installed
2) Enable in apache if not enabled already
3) Configure mod_deflate in apache:
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript
application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.[0678] no-gzip
BrowserMatch bMSIEs7 !no-gzip !gzip-only-text/html
BrowserMatch bOpera !no-gzip
Header append Vary User-Agent
AddType text/html .shtml
AddOutputFilter INCLUDES .shtml
• Or configure mod_gzip in the mod_gzip.conf
GZIP
Harder, Better, Faster, Stronger
# phase 1: (reqheader, uri, file, handler)
# ========================================
# NO: special broken browsers which request for gzipped content
# but then aren't able to handle it correctly
mod_gzip_item_exclude reqheader "User-agent: Mozilla/4.0[678]“
#YES: HTML & PHP
mod_gzip_item_include file .html$
mod_gzip_item_include file .php$
# NO: include files / JavaScript & CSS (due to Netscape4 bugs)
#mod_gzip_item_exclude file .js$
#mod_gzip_item_exclude file .css$
# YES: CGI scripts
mod_gzip_item_include file .pl$
mod_gzip_item_include handler ^cgi-script$
# phase 2: (mime, rspheader)
# YES: normal HTML files, normal text files, Apache directory listings
#mod_gzip_item_include mime ^text/html$
#mod_gzip_item_include mime ^text/plain$
mod_gzip_item_include mime ^httpd/unix-directory$
# YES: include files / JavaScript & MIME text
mod_gzip_item_include mime ^application/x-javascript
mod_gzip_item_include mime ^text/
# NO: images (GIF etc., will rarely ever save anything)
mod_gzip_item_exclude mime ^image/
Harder, Better, Faster, Stronger
Control what you cache and for how long.
1) Enable in apache:
LoadModule expires_module /path_to/modules/mod_expires.so
2) Figure out how long different content types can last until stale
3) Configure in .htaccess:
(next page)
4) Add parameters to some of your images and other static content to allow you to expire them
by image name.
i.e.
Change your reference to heroshot.jpg to heroshot.jpg?123
Now when you update that image you can change it to heroshot.jpg?124
A Browser will recognize this as a new image.
Expires Headers
Harder, Better, Faster, Stronger
EXAMPLE:
# Expires Headers
ExpiresActive on
ExpiresDefault "access plus 5 minutes"
ExpiresByType text/html "now"
ExpiresByType image/jpg "access plus 3 days"
ExpiresByType image/gif "access plus 30 days"
ExpiresByType image/png "access plus 30 days"
ExpiresByType image/x-icon "access plus 30 days"
ExpiresByType image/jpeg "access plus 30 days"
ExpiresByType text/css "access plus 30 days"
ExpiresByType text/javascript "access plus 30 days"
ExpiresByType text/js "access plus 30 days"
ExpiresByType application/x-javascript "access plus 30 days"
ExpiresByType application/javascript "access plus 30 days"
Expires Headers
Harder, Better, Faster, Stronger
• Using a CDN vs. Reduce DNS lookups
– DNS lookups are cached at the client (or their ISP) but first load time
can take time
– Parallel loading of content can occur, however, if you use a CDN
– Therefore balance is key: parallel loading of a very large javascript file
on a first time visit can be worth the extra 30+ ms for the DNS lookup
• CSS at top – allows for progressive rendering (i.e. not having
to load and THEN redraw page elements)
• JS at bottom – allows for rendering to continue before JS
blocks it, also JS will block any parallel image downloading
Misc
Harder, Better, Faster, Stronger
• David Engel
• davidengel.dev@gmail.com
• http://winnipegphp.com
• http://www.meetup.com/Winnipeg-PHP/
• http://www.linkedin.com/groups/PHP-
Winnipeg-3874131
Closing

Mais conteúdo relacionado

Mais procurados

Hidden Secrets For A Hack-Proof Joomla! Site
Hidden Secrets For A Hack-Proof Joomla! SiteHidden Secrets For A Hack-Proof Joomla! Site
Hidden Secrets For A Hack-Proof Joomla! SiteDaniel Kanchev
 
CSS and image optimization
CSS and image optimizationCSS and image optimization
CSS and image optimizationStoyan Stefanov
 
How to Speed Up Your Joomla! Site
How to Speed Up Your Joomla! SiteHow to Speed Up Your Joomla! Site
How to Speed Up Your Joomla! SiteDaniel Kanchev
 
Responsive content
Responsive contentResponsive content
Responsive contenthonzie
 
WordPress website optimization
WordPress website optimizationWordPress website optimization
WordPress website optimizationDaniel Kanchev
 
In-browser storage and me
In-browser storage and meIn-browser storage and me
In-browser storage and meJason Casden
 
Reducing latency on the web with the Azure CDN- TechDays NL 2014
Reducing latency on the web with the Azure CDN- TechDays NL 2014Reducing latency on the web with the Azure CDN- TechDays NL 2014
Reducing latency on the web with the Azure CDN- TechDays NL 2014Maarten Balliauw
 
Reducing latency on the web with the Azure CDN - DevSum - SWAG
Reducing latency on the web with the Azure CDN - DevSum - SWAGReducing latency on the web with the Azure CDN - DevSum - SWAG
Reducing latency on the web with the Azure CDN - DevSum - SWAGMaarten Balliauw
 
Speeding Up WordPress sites
Speeding Up WordPress sitesSpeeding Up WordPress sites
Speeding Up WordPress sitesJason Yingling
 
Something about node basics
Something about node basicsSomething about node basics
Something about node basicsPhilipp Fehre
 
Optimizing Your Site
Optimizing Your SiteOptimizing Your Site
Optimizing Your Sitertvenge
 
DrupalCon Barcelona 2015
DrupalCon Barcelona 2015DrupalCon Barcelona 2015
DrupalCon Barcelona 2015Daniel Kanchev
 
Create a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBCreate a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBHengki Sihombing
 
High Performance WordPress
High Performance WordPressHigh Performance WordPress
High Performance WordPressvnsavage
 
Static resource-optimization using webutilities
Static resource-optimization using webutilitiesStatic resource-optimization using webutilities
Static resource-optimization using webutilitiesrpatil82
 
Page speed optimization
Page speed optimizationPage speed optimization
Page speed optimizationBitsytask
 
Алексей Лесовский "Тюнинг Linux для баз данных. "
Алексей Лесовский "Тюнинг Linux для баз данных. "Алексей Лесовский "Тюнинг Linux для баз данных. "
Алексей Лесовский "Тюнинг Linux для баз данных. "Tanya Denisyuk
 

Mais procurados (20)

Hidden Secrets For A Hack-Proof Joomla! Site
Hidden Secrets For A Hack-Proof Joomla! SiteHidden Secrets For A Hack-Proof Joomla! Site
Hidden Secrets For A Hack-Proof Joomla! Site
 
CSS and image optimization
CSS and image optimizationCSS and image optimization
CSS and image optimization
 
How to Speed Up Your Joomla! Site
How to Speed Up Your Joomla! SiteHow to Speed Up Your Joomla! Site
How to Speed Up Your Joomla! Site
 
Frontend Caching - The "new" frontier
Frontend Caching - The "new" frontierFrontend Caching - The "new" frontier
Frontend Caching - The "new" frontier
 
Caching for Cash, part 4 DPC 2009
Caching for Cash, part 4 DPC 2009Caching for Cash, part 4 DPC 2009
Caching for Cash, part 4 DPC 2009
 
Responsive content
Responsive contentResponsive content
Responsive content
 
WordPress website optimization
WordPress website optimizationWordPress website optimization
WordPress website optimization
 
In-browser storage and me
In-browser storage and meIn-browser storage and me
In-browser storage and me
 
Reducing latency on the web with the Azure CDN- TechDays NL 2014
Reducing latency on the web with the Azure CDN- TechDays NL 2014Reducing latency on the web with the Azure CDN- TechDays NL 2014
Reducing latency on the web with the Azure CDN- TechDays NL 2014
 
Reducing latency on the web with the Azure CDN - DevSum - SWAG
Reducing latency on the web with the Azure CDN - DevSum - SWAGReducing latency on the web with the Azure CDN - DevSum - SWAG
Reducing latency on the web with the Azure CDN - DevSum - SWAG
 
Speeding Up WordPress sites
Speeding Up WordPress sitesSpeeding Up WordPress sites
Speeding Up WordPress sites
 
Something about node basics
Something about node basicsSomething about node basics
Something about node basics
 
Optimizing Your Site
Optimizing Your SiteOptimizing Your Site
Optimizing Your Site
 
DrupalCon Barcelona 2015
DrupalCon Barcelona 2015DrupalCon Barcelona 2015
DrupalCon Barcelona 2015
 
Wckansai 2014
Wckansai 2014Wckansai 2014
Wckansai 2014
 
Create a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDBCreate a RESTful API with NodeJS, Express and MongoDB
Create a RESTful API with NodeJS, Express and MongoDB
 
High Performance WordPress
High Performance WordPressHigh Performance WordPress
High Performance WordPress
 
Static resource-optimization using webutilities
Static resource-optimization using webutilitiesStatic resource-optimization using webutilities
Static resource-optimization using webutilities
 
Page speed optimization
Page speed optimizationPage speed optimization
Page speed optimization
 
Алексей Лесовский "Тюнинг Linux для баз данных. "
Алексей Лесовский "Тюнинг Linux для баз данных. "Алексей Лесовский "Тюнинг Linux для баз данных. "
Алексей Лесовский "Тюнинг Linux для баз данных. "
 

Destaque

Php 5.4: New Language Features You Will Find Useful
Php 5.4: New Language Features You Will Find UsefulPhp 5.4: New Language Features You Will Find Useful
Php 5.4: New Language Features You Will Find UsefulDavid Engel
 
PHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesPHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesEric Poe
 
Last Month in PHP - December 2015
Last Month in PHP - December 2015Last Month in PHP - December 2015
Last Month in PHP - December 2015Eric Poe
 

Destaque (6)

Php 5.4: New Language Features You Will Find Useful
Php 5.4: New Language Features You Will Find UsefulPhp 5.4: New Language Features You Will Find Useful
Php 5.4: New Language Features You Will Find Useful
 
PHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return TypesPHP7 - Scalar Type Hints & Return Types
PHP7 - Scalar Type Hints & Return Types
 
Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6Key features PHP 5.3 - 5.6
Key features PHP 5.3 - 5.6
 
Last Month in PHP - December 2015
Last Month in PHP - December 2015Last Month in PHP - December 2015
Last Month in PHP - December 2015
 
Cache is King!
Cache is King!Cache is King!
Cache is King!
 
Composer
ComposerComposer
Composer
 

Semelhante a Harder, Better, Faster, Stronger

Minimize website page loading time – 20+ advanced SEO tips
Minimize website page loading time – 20+ advanced SEO tipsMinimize website page loading time – 20+ advanced SEO tips
Minimize website page loading time – 20+ advanced SEO tipsCgColors
 
Wordpress optimization
Wordpress optimizationWordpress optimization
Wordpress optimizationpaudelvinay
 
Client Side Optimization
Client Side OptimizationClient Side Optimization
Client Side OptimizationPatrick Huesler
 
The Need for Speed - SMX Sydney 2013
The Need for Speed - SMX Sydney 2013The Need for Speed - SMX Sydney 2013
The Need for Speed - SMX Sydney 2013Bastian Grimm
 
Vinay Paudel: Optimizing and Speeding up a WordPress site
Vinay Paudel: Optimizing and Speeding up a WordPress siteVinay Paudel: Optimizing and Speeding up a WordPress site
Vinay Paudel: Optimizing and Speeding up a WordPress sitewpnepal
 
High performance website
High performance websiteHigh performance website
High performance websiteChamnap Chhorn
 
WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019Anam Ahmed
 
DrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizingDrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizingAshok Modi
 
PageSpeed Optimization
PageSpeed OptimizationPageSpeed Optimization
PageSpeed OptimizationShweta Patel
 
WordPress Theme and Plugin Optimization - WordPress Arvika March '14
WordPress Theme and Plugin Optimization - WordPress Arvika March '14WordPress Theme and Plugin Optimization - WordPress Arvika March '14
WordPress Theme and Plugin Optimization - WordPress Arvika March '14slobodanmanic
 
Page Performance
Page PerformancePage Performance
Page Performanceatorreno
 
10 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 201210 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 2012Bastian Grimm
 
Website Optimization - WordPress
Website Optimization - WordPressWebsite Optimization - WordPress
Website Optimization - WordPressAditya Shah
 
Speed Up WordPress Websites - Part 1 - WordPress Cairo Meetup
Speed Up WordPress Websites - Part 1 - WordPress Cairo MeetupSpeed Up WordPress Websites - Part 1 - WordPress Cairo Meetup
Speed Up WordPress Websites - Part 1 - WordPress Cairo MeetupAhmed Mohammed Nagdy
 
Optimizing Your WordPress Site: Why speed matters, and how to get there
Optimizing Your WordPress Site: Why speed matters, and how to get thereOptimizing Your WordPress Site: Why speed matters, and how to get there
Optimizing Your WordPress Site: Why speed matters, and how to get thereStephen Bell
 

Semelhante a Harder, Better, Faster, Stronger (20)

Minimize website page loading time – 20+ advanced SEO tips
Minimize website page loading time – 20+ advanced SEO tipsMinimize website page loading time – 20+ advanced SEO tips
Minimize website page loading time – 20+ advanced SEO tips
 
Wordpress optimization
Wordpress optimizationWordpress optimization
Wordpress optimization
 
performance.ppt
performance.pptperformance.ppt
performance.ppt
 
Client Side Optimization
Client Side OptimizationClient Side Optimization
Client Side Optimization
 
The Need for Speed - SMX Sydney 2013
The Need for Speed - SMX Sydney 2013The Need for Speed - SMX Sydney 2013
The Need for Speed - SMX Sydney 2013
 
Vinay Paudel: Optimizing and Speeding up a WordPress site
Vinay Paudel: Optimizing and Speeding up a WordPress siteVinay Paudel: Optimizing and Speeding up a WordPress site
Vinay Paudel: Optimizing and Speeding up a WordPress site
 
High performance website
High performance websiteHigh performance website
High performance website
 
WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019WordPress At Scale. WordCamp Dhaka 2019
WordPress At Scale. WordCamp Dhaka 2019
 
DrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizingDrupalCampLA 2011 - Drupal frontend-optimizing
DrupalCampLA 2011 - Drupal frontend-optimizing
 
PageSpeed Optimization
PageSpeed OptimizationPageSpeed Optimization
PageSpeed Optimization
 
Optimize wordpress
Optimize wordpressOptimize wordpress
Optimize wordpress
 
WordPress Theme and Plugin Optimization - WordPress Arvika March '14
WordPress Theme and Plugin Optimization - WordPress Arvika March '14WordPress Theme and Plugin Optimization - WordPress Arvika March '14
WordPress Theme and Plugin Optimization - WordPress Arvika March '14
 
Page Performance
Page PerformancePage Performance
Page Performance
 
10 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 201210 Tips to make your Website lightning-fast - SMX Stockholm 2012
10 Tips to make your Website lightning-fast - SMX Stockholm 2012
 
Website Optimization - WordPress
Website Optimization - WordPressWebsite Optimization - WordPress
Website Optimization - WordPress
 
Speed Up WordPress Websites - Part 1 - WordPress Cairo Meetup
Speed Up WordPress Websites - Part 1 - WordPress Cairo MeetupSpeed Up WordPress Websites - Part 1 - WordPress Cairo Meetup
Speed Up WordPress Websites - Part 1 - WordPress Cairo Meetup
 
Optimize
OptimizeOptimize
Optimize
 
Optimizing Your WordPress Site: Why speed matters, and how to get there
Optimizing Your WordPress Site: Why speed matters, and how to get thereOptimizing Your WordPress Site: Why speed matters, and how to get there
Optimizing Your WordPress Site: Why speed matters, and how to get there
 
High-Speed HTML5
High-Speed HTML5High-Speed HTML5
High-Speed HTML5
 
Speed!
Speed!Speed!
Speed!
 

Último

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 

Último (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 

Harder, Better, Faster, Stronger

  • 1. Harder, Better, Faster, Stronger How compression, reduction, and expiration can improve your site.
  • 2. Harder, Better, Faster, Stronger • Intro: Steven Souder’s 14 Rules (circa 2007) • Tools • Reducing HTTP requests • Caching • Minifying • GZIP-ing • Expires Headers Agenda
  • 3. Harder, Better, Faster, Stronger • Make Fewer HTTP Requests • Use a Content Delivery Network • Add an Expires Header • Gzip Components • Put Stylesheets at the Top • Put Scripts at the Bottom • Avoid CSS Expressions • Make JavaScript and CSS External • Reduce DNS Lookups • Minify JavaScript • Avoid Redirects • Remove Duplicate Scripts • Configure ETags • Make AJAX Cacheable Steven Souder’s 14 Rules http://stevesouders.com/hpws/rules.php
  • 4. Harder, Better, Faster, Stronger • YSLOW: Browser Add-in (Chrome, Firefox) • Note: autorun affects your PHP Sessions • http://tools.pingdom.com • https://developers.google.com/speed/pagespeed/ Tools
  • 5. Harder, Better, Faster, Stronger • CSS Sprites • http://csssprites.com/ • http://css-sprit.es/ • Mind size limits for mobile browser caching • Combine scripts and stylesheets • If not using Etags turn ‘em off in httpd.conf: Header unset Etag FileETag None Reducing HTTP Requests
  • 6. Harder, Better, Faster, Stronger Server side •Distributed: Memcached •Opcode caching: Xcache, APC Client side •Cache headers Caching
  • 7. Harder, Better, Faster, Stronger Javascript & CSS: • remove extra chars, comments & whitespace • reduce size for first page load There are many online compressors: • www.cssdrive.com There are also local compressors: • YUI compressor • LESS/SASS tools (SimpLESS, WinLESS, etc.) will minify resultant CSS. Minification
  • 8. Harder, Better, Faster, Stronger 1) Install if not installed 2) Enable in apache if not enabled already 3) Configure mod_deflate in apache: AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/javascript application/x-javascript BrowserMatch ^Mozilla/4 gzip-only-text/html BrowserMatch ^Mozilla/4.[0678] no-gzip BrowserMatch bMSIEs7 !no-gzip !gzip-only-text/html BrowserMatch bOpera !no-gzip Header append Vary User-Agent AddType text/html .shtml AddOutputFilter INCLUDES .shtml • Or configure mod_gzip in the mod_gzip.conf GZIP
  • 9. Harder, Better, Faster, Stronger # phase 1: (reqheader, uri, file, handler) # ======================================== # NO: special broken browsers which request for gzipped content # but then aren't able to handle it correctly mod_gzip_item_exclude reqheader "User-agent: Mozilla/4.0[678]“ #YES: HTML & PHP mod_gzip_item_include file .html$ mod_gzip_item_include file .php$ # NO: include files / JavaScript & CSS (due to Netscape4 bugs) #mod_gzip_item_exclude file .js$ #mod_gzip_item_exclude file .css$ # YES: CGI scripts mod_gzip_item_include file .pl$ mod_gzip_item_include handler ^cgi-script$ # phase 2: (mime, rspheader) # YES: normal HTML files, normal text files, Apache directory listings #mod_gzip_item_include mime ^text/html$ #mod_gzip_item_include mime ^text/plain$ mod_gzip_item_include mime ^httpd/unix-directory$ # YES: include files / JavaScript & MIME text mod_gzip_item_include mime ^application/x-javascript mod_gzip_item_include mime ^text/ # NO: images (GIF etc., will rarely ever save anything) mod_gzip_item_exclude mime ^image/
  • 10. Harder, Better, Faster, Stronger Control what you cache and for how long. 1) Enable in apache: LoadModule expires_module /path_to/modules/mod_expires.so 2) Figure out how long different content types can last until stale 3) Configure in .htaccess: (next page) 4) Add parameters to some of your images and other static content to allow you to expire them by image name. i.e. Change your reference to heroshot.jpg to heroshot.jpg?123 Now when you update that image you can change it to heroshot.jpg?124 A Browser will recognize this as a new image. Expires Headers
  • 11. Harder, Better, Faster, Stronger EXAMPLE: # Expires Headers ExpiresActive on ExpiresDefault "access plus 5 minutes" ExpiresByType text/html "now" ExpiresByType image/jpg "access plus 3 days" ExpiresByType image/gif "access plus 30 days" ExpiresByType image/png "access plus 30 days" ExpiresByType image/x-icon "access plus 30 days" ExpiresByType image/jpeg "access plus 30 days" ExpiresByType text/css "access plus 30 days" ExpiresByType text/javascript "access plus 30 days" ExpiresByType text/js "access plus 30 days" ExpiresByType application/x-javascript "access plus 30 days" ExpiresByType application/javascript "access plus 30 days" Expires Headers
  • 12. Harder, Better, Faster, Stronger • Using a CDN vs. Reduce DNS lookups – DNS lookups are cached at the client (or their ISP) but first load time can take time – Parallel loading of content can occur, however, if you use a CDN – Therefore balance is key: parallel loading of a very large javascript file on a first time visit can be worth the extra 30+ ms for the DNS lookup • CSS at top – allows for progressive rendering (i.e. not having to load and THEN redraw page elements) • JS at bottom – allows for rendering to continue before JS blocks it, also JS will block any parallel image downloading Misc
  • 13. Harder, Better, Faster, Stronger • David Engel • davidengel.dev@gmail.com • http://winnipegphp.com • http://www.meetup.com/Winnipeg-PHP/ • http://www.linkedin.com/groups/PHP- Winnipeg-3874131 Closing