28. How Quickling works? 1. User clicks a link or back/forward button 2. Quickling sends an ajax to server 3. Response arrives 4. Quickling blanks the content area 5. Download javascript/CSS 6. Show new content
69. PageCache Motivation: temporal locality Data accessed now is likely to be accessed again soon. Cache the data at the client: Improve latency Reduce server load
70. PageCache Cache user visited pages in browsers Some pages are likely to be revisited soon A typical user session: home -> profile -> photo -> home -> notes -> home -> photo -> photo Home page visited every 3 ~ 5 page views Back/Forward button
71. Possible solution 1 Modify HTTP headers ‘Cache-Control’, ‘Expires’ headers Cache on disk, managed by browser Pros: Easy to implement Cons: Only good for static content that rarely changes
72. Possible solution 2 Cache DOMtree Simulate tab-switching Cache in memory, managed by application with JavaScript Pros: Flexible (full control over cache with JavaScript) Restore a page from cache is super fast. Cons: Difficult to be transparent to developers Hard to isolate cache pages, global variables clobbering across pages
73. Possible solution 3 (adopted approach) Cache server response Cache server’s response Cached in memory, managed by application with JavaScript Pros: Flexible (full control over cache with JavaScript) Almost transparent to developers Cons: Have to keep track of changes made to cached response Reconstruct DOM and global JavaScript states when restoring a page
74. How PageCache works? 1. User clicks a link or back button 2. Quickling sends ajax to server 2. Find Page in the cache 3. Response arrives 3.5 Save response in cache 4. Quickling blanks the content area 5. Download javascript/CSS 6. Show new content
76. Incremental updates Poll server for incremental updates viaAJAX calls Provides an ‘onpagecacheRegister’ API to developers: Invoked when a page is restored from cache. Used to send AJAX to server for incremental updates, refresh ads, etc. Blank the content area before incremental updates arrive to avoid flash of stale contents.
78. In-page writes Record and replay Automatically record all state-changing operations in a cached page All AJAX calls using ‘POST’ method, or those explicitly specified ‘replayable’ will be added to cached content. Automatically replay those operations when cached page is restored. Cached AJAX handler callback functions already contain all the contextual information about the recorded operations due toJavaScript closure.
80. Cross-page writes Server side invalidation Instrument server-side database API, whenever a write operation is detected, send a signal to the client to invalidate the cache. The signal (a.k.a. cache invalidation message) contain information about what persistent data has changed. Upon receiving cache messages, the client side can flush the whole cache or refresh only those affected page components via AJAX.
84. Summary Quickling: Dramatically improves render time by eliminating redundant work. PageCache: improves user latency and reduces server load.
Editor's Notes
Provide functions to programmers to allow registering a javascript function to be called right before cached page is shown.Used by home page to refresh ‘ads’, fetch latest stories
Provide functions to programmers to allow registering a javascript function to be called right before cached page is shown.Used by home page to refresh ‘ads’, fetch latest stories