Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Performance Optimizing Tips

Performance Optimizing Tips

Some performance optimizing tips

Avatar for Oanh Nguyen

Oanh Nguyen

November 11, 2015
Tweet

More Decks by Oanh Nguyen

Other Decks in Programming

Transcript

  1. Content: • Web system • Web resources • How gzip

    compression works • HTTP Caching • PHP performance tips • Others
  2. Web system Database Cache DB (memcached, apc, …) Web App

    (PHP, ASP, JSP, …) Web resources (css, js, img, …) Web server + HTTP Cache Web browser, App client
  3. HTML • Use HTML 5: new, lightweight, … • According

    to the HTML 4 DTD, you can omit the following tags. • Combine external JavaScript files • Include external CSS files before external JavaScript files
  4. CSS • Remove unused CSS. • Using every declaration just

    once means making strict use of selector grouping. • Minify CSS files.
  5. Javascript (js) • Optimizing JavaScript code • Speeding up JavaScript:

    Working with the DOM • Minify JavaScript • Compressing your JavaScript with Closure Compiler • Use Asynchronous load
  6. Images & Web graphics • Compress images (TinyPNG) • Use

    a lot of small images on big images • Use lazy load • Optimizing canvas draw
  7. Gzip • Browser: • Connects to server. • Notifies server

    that browser supports gzip "Accept-Encoding: gzip". • Server: • Acknowledges gzip support. • Sends gzip encoded page with header "Content-Encoding: gzip". • Browser: • Receive page. • Decode gzip encoded page based on header "Content-Encoding: gzip". • Display page.
  8. PHP performance tips • Upgrade your version of PHP •

    Use caching • Use output buffering • Avoid writing naive setters and getters • Don't copy variables for no reason • Avoid doing SQL queries within a loop • Sometimes, performance of native PHP function is not best
  9. Others • Using HTML 5 for performance improvements • Store

    web resources on diff • Reduce the number of requests and the amount of data transferred
  10. Q&A