title: django-mobile views rendered to the desktop & vice-versa when using caching
body: <p>I've got a project running Django CMS and <a href="https://github.com/gregmuellegger/django-mobile" rel="nofollow">django-mobile</a> for rendering different templates to mobile defines.</p>
  
  <p>With page caching enabled in Django CMS it's possible to see the full mobile template displayed on a desktop browser or the other way around; desktop on mobile.</p>
  
  <p>From some Google docs, I believed the resolution to this was setting middleware for <code>patch_vary_headers</code>;</p>
  
  <pre><code>from django.utils.cache import patch_vary_headers
  
  
  class VaryHeaderMiddleware(object):
      def process_response(self, request, response):
          # Set Vary Header based on
          # https://developers.google.com/webmasters/smartphone-sites/details
  
          patch_vary_headers(response, ['User-Agent'])
  
          return response
  </code></pre>
  
  <p>With the <code>CMS_PAGE_CACHE</code> disabled I've not seen full page templates rendered to the wrong devices, but I have got a page which as rendered with the desktop template, but then the apps rendered to the page through CMS placeholders have rendered their mobile template to the desktop. And this is while <code>CMS_PLACEHOLDER_CACHE</code> and <code>CMS_PLUGIN_CACHE</code> are still enabled.</p>
  
  <p>Now I've just found this <a href="https://code.djangoproject.com/ticket/15855" rel="nofollow">bug report</a> from Django that suggests it's possible to omit the vary header when using the page caching decorator, but can this happen at a broader scale if I'm seeing mis-matched template rendering while certain elements are being cached?</p>
  
  <p>I'm running the latest django-mobile 0.5.0 and I believe all middleware classes are defined in the correct order;</p>
  
  <pre><code>    'project.middleware.VaryHeaderMiddleware',
      'django_mobile.middleware.MobileDetectionMiddleware',
      'django_mobile.middleware.SetFlavourMiddleware',
      'django_mobile.cache.middleware.CacheFlavourMiddleware',
      'django.middleware.cache.FetchFromCacheMiddleware',
  )
  </code></pre>