title: Nginx memcache caching and invalidation
body: <p>We currently use NGINX as our server, we use memcache to cache db queries as well as pages in php.</p>
  
  <p>We have a version numbering system where in any update or insert happens this version number is bumped up, as a result memcache will always fetch new data as each key is appended with this version number. It works for us as read write % split is at 80/20 % so most of the times memcache is going to return the data without hitting the DB.</p>
  
  <p>Now we plan to move this caching strategy to the server level where NGINX along with the memcache module will cache GET requests using the request uri along with the version number.</p>
  
  <p>Just needed some feedback on how i can achieve this</p>
  
  <ul>
  <li>Can i fetch this version number which is stored in memcache in NGINX? (this will be used to append it to the request uri)</li>
  <li>How do i handle logged in users? (can I just set a cookie for a logged in user and check if this cookie exists in nginx if it does just pass the request to backend instead of memcache)</li>
  </ul>