caching strategy and apc
DESCRIPTION
Presentation about Cache strategy for your website and uTRANSCRIPT
![Page 1: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/1.jpg)
Caching Strategy & APC
Vo Duy Tuan - CEO/Founder
From the PHP developer view
![Page 2: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/2.jpg)
$who_am_I?
My Name is Võ Duy Tuấn PHP 5 Zend Certified Engineer Interests: PHP, Social Network, Optimize Web Works:
Reader.vn CEO/Founder Trainer Freelancer Help customer Optimize & Speed up website
![Page 3: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/3.jpg)
Caching Strategy1
![Page 4: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/4.jpg)
1.1. Web Caching Introduction
![Page 5: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/5.jpg)
1.2. Cache Strategy
Heavy load page/module HIT & MISS ratio. Budget & Technology AJAX SEO friendly Seperating to small tactics
Cache WHERE ? Cache WHAT ? Cache HOW LONG ?
![Page 6: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/6.jpg)
1.2.1. Cache WHERE?
![Page 7: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/7.jpg)
1.2.2. Cache WHAT?
File Code Query Result Object Array String Number …
![Page 8: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/8.jpg)
1.2.3. Cache HOW LONG?
Cache Clear Type: Never Expired Normal Expired Force Expired
“More time caching, less real time data.”
![Page 9: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/9.jpg)
Which cache do you HATE most?
![Page 10: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/10.jpg)
Alternative PHP Cache - APC2
![Page 11: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/11.jpg)
2.1. What is APC?
Free PHP Extension PHP Opcode cache Support User data cache Run on SAME machine with PHP NOT support multi servers
![Page 12: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/12.jpg)
![Page 13: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/13.jpg)
2.2. APC Installation
On linux: pecl install apc
On Windows: Download apc DLL file to PHP extension directory
such as php_apc.dll
![Page 14: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/14.jpg)
2.3. PHP.INI
extension=/home/path/to/apc.so
[apc]
apc.enabled = 1
apc.cache_by_default=0
apc.shm_segments=1
apc.optimization=0
apc.shm_size=128
apc.ttl=7200
apc.user_ttl=7200
![Page 15: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/15.jpg)
phpinfo()
![Page 16: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/16.jpg)
2.4. APC Monitor
![Page 17: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/17.jpg)
![Page 18: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/18.jpg)
![Page 19: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/19.jpg)
2.5. APC Using
![Page 20: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/20.jpg)
![Page 21: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/21.jpg)
2.6. APC Tip
Opcode your web code only Disable APC for PhpMyAdmin
<Directory "/mysite/public_html/">
...
php_admin_flag apc.cache_by_default On
</Directory
<Directory "/mysite/public_html/phpmyadmin/">
...
php_admin_flag apc.cache_by_default Off
</Directory>
![Page 22: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/22.jpg)
2.6. APC Tip..
Cache STRING is better than ARRAY Long Time To Live better than Short Case study:
Caching for Feed System:
![Page 23: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/23.jpg)
BEFORE
![Page 24: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/24.jpg)
BEFORE
![Page 25: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/25.jpg)
ANALYSE
![Page 26: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/26.jpg)
AFTER
![Page 27: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/27.jpg)
Short TTL make fragmentation
![Page 28: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/28.jpg)
Short TTL make fragmentation
![Page 29: Caching strategy and apc](https://reader036.vdocuments.site/reader036/viewer/2022062704/5559ffb2d8b42ad00a8b4df2/html5/thumbnails/29.jpg)
It’s time to query …
Thanks you!