SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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 для баз данных. "
 

Andere mochten auch

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
 

Andere mochten auch (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
 

Ähnlich wie 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
 

Ähnlich wie 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!
 

Kürzlich hochgeladen

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesZilliz
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024The Digital Insurer
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 

Kürzlich hochgeladen (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
Vector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector DatabasesVector Databases 101 - An introduction to the world of Vector Databases
Vector Databases 101 - An introduction to the world of Vector Databases
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024My INSURER PTE LTD - Insurtech Innovation Award 2024
My INSURER PTE LTD - Insurtech Innovation Award 2024
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 

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