title: What strategies do you use for fetching and caching paginated collections, specifically in angular or restangular?
body: <p>Let's say an app consumes data from a REST api that exposes paginated collections, and the number of items in a collection can be infinitely large (i.e. too many items to fetch all at once and store in a browser session).</p>
  
  <p>What are good strategies for fetching, caching and invalidating the cache of such data? </p>
  
  <p>Say, the API is like,</p>
  
  <pre><code>GET /users?page=1&amp;per_page=50
  </code></pre>
  
  <p>With a response like below (i.e. includes the collection data + paging meta data)</p>
  
  <pre><code>{
    "paging": {
      "per_page": 20,
      "page": 1,
      "previous": null,
      "self": "/api/v1/users?per_page=20&amp;page=1",
      "next": "/api/v1/users?per_page=20&amp;page=2"
    },
    "data": [
      // first 20 users
    ]
  }
  </code></pre>
  
  <p>The client may or may not load the collection in contiguous pages, one page at a time. The users in the collection may be changed, by any client. Eventual consistency is sufficient and I'm not concerned about write conflicts at this time.</p>
  
  <p>The question is in the context of an angularjs app, but is a generic scenario.</p>