Read Excerpt: Table of Contents (PDF) - Wiley India

hastywittedmarriedInternet και Εφαρμογές Web

8 Δεκ 2013 (πριν από 3 χρόνια και 8 μήνες)

64 εμφανίσεις

CONTENTS
INTRODUCTION xxiii
PART I: FRONT END
CHAPTER 1: A REFRESHER ON WEB BROWSERS 3
A Brief History of Web Browsers 3
Netscape Loses Its Dominance 4
The Growth of Firefox 4
The Present 5
Inside HTTP 5
The HyperText Transfer Protocol 5
HTTP Versions 8
Support for Virtual Hosting 9
Caching 9
How Browsers Download and Render Content 10
Rendering 11
Persistent Connections and Keep-Alive 12
Parallel Downloading 14
Summary 21
CHAPTER 2: UTILIZING CLIENT-SIDE CACHING 23
Understanding the Types of Caching 23
Caching by Browsers 23
Intermediate Caches 24
Reverse Proxies 25
Controlling Caching 25
Conditional GETs 25
Utilizing Cache-Control and Expires Headers 28
Choosing Expiration Policies 30
Coping with Stale Content 30
How Not to Cache 31
Dealing with Intermediate Caches 31
Cache-Control Revisited 31
Caching HTTP Responses 32
The Shift in Browser Behavior 32
Using Alternative 3xx Codes 34
f
t
o
c
.
i
n
d
d



x
i
i
i
ftoc.indd xiii
0
2
/
1
1
/
1
2



4
:
2
2

P
M
02/11/12 4:22 PM
COPYRIGHTED MATERIAL
xiv
CONTENTS
DNS Caching and Prefetching 34
The DNS Resolution Process 35
DNS Caching by the Browser 35
How DNS Lookups Aff ect Performance 36
DNS Prefetching 36
Controlling Prefetching 37
Summary 37
CHAPTER 3: CONTENT COMPRESSION 39
Who Uses Compression 39
Understanding How Compression Works 41
Compression Methods 42
Other Compression Methods 47
Transfer Encoding 48
Compression in PHP 49
Compressing PHP-Generated Pages 49
Compressing Other Resources 51
Summary 51
CHAPTER 4: KEEPING THE SIZE DOWN WITH MINIFICATION 53
JavaScript Minifi cation 54
YUI Compressor 55
Google Closure 56
Comparison of JavaScript Minifi ers 58
CSS Minifi cation 59
Use Shorthand 59
Grouping Selectors 60
CSS Minifi ers 60
Improving Compression 62
HTML Minifi cation 63
HTML Minifi cation Techniques 64
HTML Minifi cation Tools 66
Summary 69
CHAPTER 5: OPTIMIZING WEB GRAPHICS AND CSS 71
Understanding Image Formats 71
JPEG 72
GIF 72
PNG 73
SVG 73
ftoc.indd xiv
ftoc.indd xiv
02/11/12 4:22 PM
02/11/12 4:22 PM
xv
CONTENTS
Optimizing Images 74
Image Editing Software 74
Choosing the Right Format 74
Interlacing and Progressive Rendering 75
PNG Optimization 77
GIF Optimization 80
JPEG Compression 80
Image Optimization Software 84
Data URIs 85
Favicons 85
Using Lazy Loading 87
Avoiding Empty src attributes 88
Using Image Maps 89
CSS Sprites 91
Sprite Strategies 94
Repeating Images 94
CSS Performance 99
CSS in the Document Head 100
Inline versus External 100
Link versus @import 100
Redundant Selectors 100
CSS Expressions 101
Selector Performance 102
Using Shorthand Properties 102
Inheritance and Default Values 104
Doing More with CSS 104
Looking Forward 109
MNG 109
APNG 109
JPEG 2000 110
Summary 110
CHAPTER 6: JAVASCRIPT, THE DOCUMENT OBJECT MODEL,
AND AJAX 111
JavaScript, JScript, and ECMAScript 112
A Brief History of JavaScript 112
JavaScript Engines 112
The Document Object Model 115
Manipulating the DOM 117
Refl owing and Repainting 117
Browser Queuing 119
ftoc.indd xv
ftoc.indd xv
02/11/12 4:22 PM
02/11/12 4:22 PM
xvi
CONTENTS
Event Delegation 119
Unobtrusive JavaScript 120
Memory Management 121
Getting the Most from JavaScript 122
Language Constructs 122
Loading JavaScript 127
Nonblocking of JavaScript Downloads 128
Merging, Splitting, and Inlining 130
Web Workers 134
Ajax 136
XMLHttpRequest 136
Using Ajax for Nonblocking of JavaScript 137
Server Responsiveness 137
Using Preemptive Loading 138
Ajax Frameworks 138
Summary 138
PART II: BACK END
CHAPTER 7: WORKING WITH WEB SERVERS 141
Apache 141
Working with Modules 142
Deciding on Concurrency 145
Improving Logging 146
Miscellaneous Performance Considerations 148
Examining Caching Options 150
Using Content Compression 155
Looking Beyond Apache 158
Nginx 158
Nginx, Apache, and PHP 164
The Best of the Rest 168
Multiserver Setups with Nginx and Apache 169
Nginx as a Reverse Proxy to Apache 170
Proxy Options 171
Nginx and Apache Side by Side 172
Load Balancers 173
Hardware versus Software 173
Load Balancer Features 174
Using Multiple Back-End Servers 176
HAProxy 181
Summary 191
ftoc.indd xvi
ftoc.indd xvi
02/11/12 4:22 PM
02/11/12 4:22 PM
xvii
CONTENTS
CHAPTER 8: TUNING MYSQL 193
Looking Inside MySQL 194
Understanding the Storage Engines 195
MyISAM 195
InnoDB 196
MEMORY 197
ARCHIVE 198
Tuning MySQL 198
Table Cache 198
Thread Caching 202
Per-Session Buff ers 204
Tuning MyISAM 205
Key Cache 205
Miscellaneous Tuning Options 210
Tuning InnoDB 211
Monitoring InnoDB 211
Working with Buff ers and Caches 212
Working with File Formats and Structures 217
Memory Allocation 218
Threading 219
Disk I/O 219
Mutexes 222
Compression 223
Working with the Query Cache 225
Understanding How the Query Cache Works 225
Confi guring the Query Cache 227
Inspecting the Cache 228
The Downsides of Query Caching 232
Optimizing SQL 234
EXPLAIN Explained 234
The Slow Query Log 237
Indexing 239
Query Execution and Optimization 247
Query Cost 248
Tips for SQL Effi ciency 249
Summary 254
CHAPTER 9: MYSQL IN THE NETWORK 255
Using Replication 256
The Basics 256
ftoc.indd xvii
ftoc.indd xvii
02/11/12 4:22 PM
02/11/12 4:22 PM
xviii
CONTENTS
Advanced Topologies 264
Replication Performance 270
Miscellaneous Features of Replication 273
Partitioning 273
Creating Partitions 274
Deciding How to Partition 276
Partition Pruning 276
Physical Storage of Partitions 277
Partition Management 278
Pros and Cons of Partitioning 278
Sharding 279
Lookup Tables 280
Fixed Sharding 281
Shard Sizes and Distribution 281
Sharding Keys and Accessibility 281
Cross-Shard Joins 282
Application Modifi cations 283
Complementing MySQL 283
MySQL Proxy 283
MySQL Tools 286
Alternatives to MySQL 294
MySQL Forks and Branches 294
Full-Text Searching 296
Other RDBMSs 307
Summary 308
CHAPTER 10: UTILIZING NOSQL SOLUTIONS 309
NoSQL Flavors 310
Key-Value Stores 310
Multidimension Stores 310
Document Stores 311
memcache 311
Installing and Running 312
membase — memcache with Persistent Storage 321
MongoDB 325
Getting to Know MongoDB 325
MongoDB Performance 328
Replication 339
Sharding 343
Other NoSQL Technologies 353
Tokyo Cabinet and Tokyo Tyrant 354
CouchDB 354
ftoc.indd xviii
ftoc.indd xviii
02/11/12 4:22 PM
02/11/12 4:22 PM
xix
CONTENTS
Project Voldemort 355
Amazon Dynamo and Google BigTable 355
Riak 356
Cassandra 356
Redis 356
HBase 356
Summary 356
CHAPTER 11: WORKING WITH SECURE SOCKETS LAYER (SSL) 359
SSL Caching 360
Connections, Sessions, and Handshakes 360
Abbreviated Handshakes 360
SSL Termination and Endpoints 364
SSL Termination with Nginx 365
SSL Termination with Apache 366
SSL Termination with stunnel 367
SSL Termination with stud 368
Sending Intermediate Certifi cates 368
Determining Key Sizes 369
Selecting Cipher Suites 369
Investing in Hardware Acceleration 371
The Future of SSL 371
OCSP Stapling 371
False Start 372
Summary 372
CHAPTER 12: OPTIMIZING PHP 375
Extensions and Compiling 376
Removing Unneeded Extensions 376
Writing Your Own PHP Extensions 378
Compiling 379
Opcode Caching 381
Variations of Opcode Caches 381
Getting to Know APC 382
Memory Management 382
Optimization 382
Time-To-Live (TTL) 382
Locking 383
Sample apc.ini 384
APC Caching Strategies 384
Monitoring the Cache 386
Using APC as a Generic Cache 386
ftoc.indd xix
ftoc.indd xix
02/11/12 4:22 PM
02/11/12 4:22 PM
xx
CONTENTS
Warming the Cache 387
Using APC with FastCGI 387
Compiling PHP 388
phc 388
Phalanger 388
HipHop 388
Sessions 389
Storing Sessions 389
Storing Sessions in memcache/membase 390
Using Shared Memory or tmpfs 390
Session AutoStart 391
Sessions and Caching 391
Effi cient PHP Programming 392
Minor Optimizations 392
Major Optimizations 392
Garbage Collection 395
Autoloading Classes 396
Persistent MySQL Connections 396
Profi ling with xhprof 398
Installing 398
A Simple Example 399
Don’t Use PHP 401
Summary 401
PART III: APPENDIXES
APPENDIX A: TCP PERFORMANCE 405
The Three-Way Handshake 405
TCP Performance 408
Nagle’s Algorithm 408
TCP_NOPUSH and TCP_CORK 408
APPENDIX B: DESIGNING FOR MOBILE PLATFORMS 409
Understanding Mobile Platforms 409
Responsive Content 410
Getting Browser Display Capabilities with JavaScript 411
Server-Side Detection of Capabilities 411
A Combined Approach 412
CSS3 Media Queries 413
Determining Connection Speed 413
ftoc.indd xx
ftoc.indd xx
02/11/12 4:22 PM
02/11/12 4:22 PM
xxi
CONTENTS
JavaScript and CSS Compatibility 414
Caching in Mobile Devices 414
APPENDIX C: COMPRESSION 417
The LZW Family 417
LZ77 417
LZ78 418
LZW 419
LZ Derivatives 420
Huff man Encoding 421
Compression Implementations 424
INDEX 427
ftoc.indd xxi
ftoc.indd xxi
02/11/12 4:22 PM
02/11/12 4:22 PM