PHP caching

From xoa
Jump to: navigation, search

Latency is the most important part of speed

Cache strategies & levels

  • Browser
  • Content proxying
  • Pre-generating content
  • Active data caching
  • Backend caches

APC is drop-in & use. It's old hat now.

Tweak APC if you have

  • large # of files (>1024)
  • Large footprint (>64M)
  • a mess of include_onces
  • highly OOP design
  • very static PHP files
  • rsync and inode re-use

APC tuneables apc.ini apc.shm_size (64M) apc.num_files_hint (512) apc.stat (On) apc.stat_ctime (Off) apc.include_once_override (Off) apc.filters () apc.localcache (Off)

APC monitoring Monitor using apc.php in the package

  • memory usage
  • fragmentation
  • cache request/insert rates
  • expunge/cache-full count

Reduce include/include_once calls

Use full include paths

  • include("./z.php") instead of include("z.php")

Use constant includes, not include($foo)

  • Don't wrap include with your functions

Avoid eval() at all costs

Inclued

  • New extension he just wrote that maps out all the include mappings.

Update your cache out of band. cron & curl are APC's friends.

Always check APC info for cache full count and fragmentation

Personal tools