Más contenido relacionado La actualidad más candente (20) Similar a Caching your rails application (20) Caching your rails application5. Browser speed
• Firebug / Safari developer
• YSlow
• Different parts of a site
6. Webpage parts
• Page itself (<html> ... )
• Additional files (CSS, JavaScript)
• Images
• ... generating dynamic content
7. Siteparts
• 10 requests:10 times slower as one request
• stylesheet_tag :defaults, ‘screen’, :cache => ‘all’
9. images
• asset hosts
• Content Delivery Network
11. Why?
• Code parsing: 20 to 50 req/second
• Webserver: easily > 100 req/sec
• Webserver stresses less, less database queries
• Why not, it is easy (with rails)...
18. Why not expire_page in
the action?
• Not DRY (update, create, destroy,...)
• after_filter possible, but other controllers
might need to expire the cache
19. after_filter
• PostsController (clear_posts_cache)
• CommentsController (clear_posts_cache)
20. sweeper
• observer on controller and model
• if saved, call clear_posts_cache
• if deleted, call clear_posts_cache
25. Action cache
• Cached output stored
• Filters are processed before the cached
version is returned to the browser
• Example: authenticatie
27. action cache
• Filter is executed before sending the reply
• Output is the same for everyone!
31. Action Caching
• when?
• execute code on each hit (authentication)
• result remains the same
• very easy to implement
40. Storage: action /
fragment cache
• memory (default) or syncronised memory
• file on disk
• drb
• memcache (normal or compressed)
• custom_store (not hard to impelement!)
42. DYI caching
• Caching hard parts in the code
• Only spend cycles when really needed
47. etag
• rails has this embedded
• MD5(body) => etag
• 304 Not Modified
48. etag
• Beware, the complete parsing is done!
• Less bandwidth / traffic
• Client load time faster
52. Memcached
• Daemon
• Is a big hash in memory
• Rails has default routines for this
• Hoster / setup should support this
53. Reverse Proxy’s
• a proxy, but on the server side
• controle over expiry: max_age + etag
• expiry remains a pain
55. Need for speed?
• Database (n+1, joins / includes)
• Disk IO
• Implementing caching
• Browser caching
• External components (CDN, memcached, ...)