title: Django - LogoutView - cache_control - browser's back button has the logged out user's cache
body: <p>Django 2.1.7</p>
  <p>This is for a simple blog with homepage (post list view), post detail view, and profile (post list view)</p>
  <p>When a user logs out, <code>LOGOUT_REDIRECT_URL = '/' </code> redirects the user to the homepage.</p>
  <p><strong>However, when the user clicks the browser's back button, the previous page still shows all the logged out user's data. When I reload the page, it clears the cache.</strong></p>
  <p>when the user's logged in, shows username]</p>
  <p><a href="https://i.stack.imgur.com/UXHHq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/UXHHq.png" alt="when the user's logged in, shows username" /></a></p>
  <p>when the user's logged out, shows 'login'</p>
  <p><a href="https://i.stack.imgur.com/NWGsF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NWGsF.png" alt="when the user's logged out, shows 'login'" /></a></p>
  <p>I found a similar question and their answer was to use the cache_control decorator.
  <a href="https://stackoverflow.com/questions/28000981/django-user-re-entering-session-by-clicking-browser-back-button-after-logging">Django - User re-entering session by clicking browser back button after logging out</a></p>
  <pre><code>@cache_control(no_cache=True, must_revalidate=True, no_store=True)
  @login_required
  </code></pre>
  <ul>
  <li>Would I have to add these decorators to every single view?</li>
  <li>I do not want the <code>@login_required</code> decorator. AnonymousUsers should be able to view all pages without logging in.</li>
  </ul>
  <p>What's the best way to do this? Similar to Twitter's logout flow. (user logs out -&gt; login page -&gt; back button -&gt; previous page but reloaded)</p>
  <p>urls.py</p>
  <pre><code>from django.contrib.auth import views as auth_views
  urlpatterns = [
  path('logout/', auth_views.LogoutView.as_view(template_name='users/logout.html'), name='logout'),
  </code></pre>