title: CGI script not executing every page visit
body: <p>I have a CGI script that generates a file on the server and then redirects the browser to that newly generated file.  </p>
  
  <pre><code>#!/bin/bash
  printf "Content-type: text/html\n\n";
  cat /myspecialdir/foo &gt; /httpd/foo.html
  echo "&lt;HTML&gt;&lt;HEAD&gt;&lt;BODY&gt;"
  echo "&lt;META HTTP-EQUIV=\"CACHE-CONTROL\" CONTENT=\"NO-CACHE\"&gt;"
  echo "&lt;META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=/foo.html\"&gt;"
  echo "&lt;/BODY&gt;&lt;/HEAD&gt;&lt;/HTML&gt;"
  </code></pre>
  
  <p>The file /myspecialdir/foo contains some dynamic content that I want to be in /httpd/foo.html.  I then want the script to redirect there after the generation of the new file.  </p>
  
  <p>The problem I have is that the script doesn't get new data on every hit from a browser.  For example, if I visit <a href="http://myip/cgi-bin/genfoo.cgi" rel="nofollow noreferrer">http://myip/cgi-bin/genfoo.cgi</a> the first time in IE the data gets generated and it gets redirected to foo.html.  After that, if I go to the CGI page using the back button, it doesn't re-run and I get redirected to stale data.  </p>
  
  <p>How can I force the CGI script to execute even from the back button?</p>
  
  <p><strong>EDIT</strong>:  I tried doing this with the HTTP headers approach, but this doesn't seem to be working.  Here's the new script, am I missing something?</p>
  
  <pre><code>#!/bin/bash
  cat /myspecialdir/foo &gt; /httpd/foo.txt
  printf "Pragma-directive: no-cache\n\n";
  printf "Cache-directive: no-cache\n\n";
  printf "Cache-control: no-cache\n\n";
  printf "Pragma: no-cache\n\n";
  printf "Expires: 0\n\n";
  printf "Location: /foo.txt\n\n";
  printf "Content-type: text/html\n\n";
  </code></pre>
  
  <p>All this does when I visit via IE is to print the headers in the page, like so:</p>
  
  <p>Pragma-directive: no-cache</p>
  
  <p>Cache-directive: no-cache</p>
  
  <p>Cache-control: no-cache</p>
  
  <p>Pragma: no-cache</p>
  
  <p>Expires: 0</p>
  
  <p>Location: /BACtrace.txt</p>
  
  <p>Content-type: text/html</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>It turns out this was an issue with the HTTP server I was using (busybox v1.12.1).  I was unable to send the HTTP headers as originally recommended, but I was able to get this to work with a combination of META tags and a setting in IE8 (Tools --> Internet Options --> Browsing History --> Settings Button --> check "Every time I visit a website").   </p>
  
  <p>The META tags I used are:</p>
  
  <pre><code>echo "&lt;meta http-equiv=\"expires\" content=\"0\" /&gt;"
  echo "&lt;META HTTP-EQUIV=\"Pragma-directive\" CONTENT=\"no-cache\"/&gt;"
  echo "&lt;META HTTP-EQUIV=\"Cache-directive\" CONTENT=\"no-cache\"/&gt;"
  echo "&lt;META HTTP-EQUIV=\"Cache-control\" CONTENT=\"no-cache\"/&gt;"
  echo "&lt;META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\"/&gt;"
  echo "&lt;META HTTP-EQUIV=\"Refresh\" CONTENT=\"1; URL=/foo.txt\"/&gt;"
  </code></pre>