title: http.FileServer caching files and serving old versions after edit
body: <p>Having issues with the http package in the core of go. It appears that the file contents is cached although the Content-Length in the response body is correct. To demonstrate here is a simplified version of the application I am writing.</p>
  
  <pre><code>package main
  
  import (
      "fmt"
      "net/http"
  )
  
  func main() {
      http.Handle("/", http.FileServer(http.Dir("./www/")))
      err := http.ListenAndServe(":8080", nil)
      if err != nil {
          fmt.Println(err)
      }
  }
  </code></pre>
  
  <p>Now suppose we have a very simple html page:</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html&gt;
  &lt;body&gt;
      &lt;p&gt;Hello there&lt;/p&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I execute the go program and access <code>http://localhost:8080</code> in the browser to be presented with:</p>
  
  <pre><code>Hello there
  </code></pre>
  
  <p>Checking the response headers I can see the following:</p>
  
  <pre><code>Status Code:200 OK
  Accept-Ranges:bytes
  Content-Length:68
  Content-Type:text/html; charset=utf-8
  Date:Fri, 20 Dec 2013 10:04:03 GMT
  Last-Modified:Fri, 20 Dec 2013 10:03:32 GMT
  </code></pre>
  
  <p>Now I edit the html file so the <code>&lt;p&gt;</code> tag contains <code>Hello there everyone</code> and reload the page. I get the following:</p>
  
  <pre><code>Hello there
  </code></pre>
  
  <p>Again looking at the response headers I get</p>
  
  <pre><code>Status Code:200 OK
  Accept-Ranges:bytes
  Content-Length:77
  Content-Type:text/html; charset=utf-8
  Date:Fri, 20 Dec 2013 10:04:34 GMT
  Last-Modified:Fri, 20 Dec 2013 10:04:14 GMT
  </code></pre>
  
  <p>So the <code>Content-Length</code> has changed as well as last modified but not the actual file content delivered by the http.FileServer handler. This issue happens even after closing the program down and doing <code>go run src/.../main.go</code>. The only way I have found so far to clear the apparently cached version of the file is to reboot the machine the program is running on.</p>
  
  <p>I have tried the following:</p>
  
  <ul>
  <li>Executing program on win / ubuntu / osx 10.8.5</li>
  <li>Going through the chain of functions / interfaces on golang.org/src to see if the served file is cached on disk anywhere</li>
  </ul>
  
  <p>Any help with this would be very much appreciated.</p>