title: How to detect whether user reached webpage by link, ctrl+r or ctrl+shift+r reloads
body: <p>How can I detect how a user reached a page? Link, reload (clear-cached or not?) in chrome?</p>
  
  <p>I am using angular. My response header contains: </p>
  
  <pre><code>Cache-Control:max-age=3600
  Last-Modified:Tue, 19 May 2015 06:19:02 GMT
  </code></pre>
  
  <p>1) This behaves as expected, when I reload (<kbd>ctrl</kbd>+<kbd>r</kbd>) the request for all files contain</p>
  
  <pre><code>Cache-Control:max-age=0
  If-Modified-Since:Tue, 19 May 2015 06:19:02 GMT
  </code></pre>
  
  <p>If the file is not modified I get </p>
  
  <pre><code>Status Code:304 Not Modified
  </code></pre>
  
  <p>2) If I reload with (<kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>r</kbd>) or reach the website first time I get</p>
  
  <pre><code>Cache-Control:no-cache
  Pragma:no-cache
  </code></pre>
  
  <p>and the file is fetched anew.</p>
  
  <p>3) If I go to the webpage through a link it loads files from cache if they have been fetched &lt;3600 seconds before also.</p>
  
  <pre><code>Status Code:200 OK (from cache)
  </code></pre>
  
  <p><strong>EXCEPT html files which I load with ng-include src="''"</strong></p>
  
  <p>They are always fetched from cache. I have to delete the cache of the whole browser for them to be fetched newly. Even <kbd>ctrl</kbd>+<kbd>shift</kbd>+<kbd>r</kbd> doesn't work. Disable cache in developer tools works as in it stops caching. </p>
  
  <p>So I added somethings to my angular app config.</p>
  
  <pre><code>$httpProvider.defaults.headers.get['Cache-Control'] = 'no-cache';
  $httpProvider.defaults.headers.get['Pragma'] = 'no-cache';
  </code></pre>
  
  <p>After this only html templates are always fetched newly. I have noticed that chrome also uses below two request headers</p>
  
  <pre><code>Cache-Control: 'no-cache'
  Pragma: 'no-cache'
  </code></pre>
  
  <p>and such files obey cache rules, except .html templates. Why?</p>
  
  <p>If I change the above lines to</p>
  
  <pre><code>$httpProvider.defaults.headers.get['Cache-Control'] = 'max-age=x';
  </code></pre>
  
  <p>then it works as expected, fetch from cache till expires and then check if not modified on server from cache. But this way it will not obey the <kbd>ctrl</kbd>+<kbd>r</kbd> reload where chrome sends </p>
  
  <pre><code>Cache-Control:max-age=0
  </code></pre>
  
  <p>So how can I detect how the user reached the webpage in chrome/firefox/etc.?</p>
  
  <p>Another alternative is to make angular $http always use the same headers like chrome when it fetches a file? right? That is always mimic browser http calls</p>
  
  <p>How fool-proof is checking <code>document.referrer</code>?</p>