2

I am trying to build a simple web app on the revel go web framework. For some reason, files in the public directory are not loaded correctly when I open their URLs in the browser. For example, an older version of the file may appear (even after reloading in the browser), or a truncated version shows up.

Anyone encountered this issue?

user1094206
  • 920
  • 1
  • 12
  • 24
  • 1
    Try a `curl -I http://url/to/file.jpg` and see if a `Cache-Control` or `Expires` header is being set (or check the source code). – elithrar Aug 05 '13 at 02:09
  • I tried it and I get the following output: `HTTP/1.1 200 OK Accept-Ranges: bytes Content-Disposition: inline; filename=droparea.css Content-Length: 645 Content-Type: text/css; charset=utf-8 Date: Mon, 05 Aug 2013 23:03:46 GMT Last-Modified: Mon, 05 Aug 2013 23:02:51 GMT Set-Cookie: REVEL_FLASH=; Path=/ Set-Cookie: REVEL_SESSION=56490577f9ae482388651378bc5c746a230c35fe-%00_TS%3A1378335826%00; Path=/; Expires=Wed, 04 Sep 2013 23:03:46 UTC` – user1094206 Aug 05 '13 at 23:04
  • Additionally, curl retrieves an old version of the file. Restarting revel doesn't seem to make a difference. – user1094206 Aug 05 '13 at 23:05
  • There is an `Expires` header in there. You're not in my timezone (so I can't figure out if it's in the 'future' for you) but if the date provided by Expires is > than the time, your browser will cache the files and not check until that time is exceeded as there is no requirement to re-validate. You could always force a hard reload (Ctrl/Cmd+R) in your browser as an interim measure, or version your CSS: `droparea.css?v={{ time.Now().UTC() }}` – elithrar Aug 05 '13 at 23:13
  • Interestingly, the expires date is in the past. I also tried changing code and hot reload doesn't seem to work even though i'm running in dev mode.. something's fishy here – user1094206 Aug 06 '13 at 00:42
  • It may be related to this: https://groups.google.com/forum/#!msg/revel-framework/hTFmGQFxj0g/ECE4T4wnoX0J – user1094206 Aug 06 '13 at 00:52
  • You can get around that if you mount the shared folder via NFS in your Vagrantfile :) – elithrar Aug 06 '13 at 01:23
  • Btw, what really surprises me is that curl returns an old version of the file even after restarting revel. Where is it caching that old version? – user1094206 Aug 06 '13 at 01:33

1 Answers1

0
  • Is GOPATH set up in the same location you are developing?
  • Are more copies of that file in your gopath?
  • Could you try to run strace -e open revel run my/app/name | grep file.jpg and see what is the location that revel is using?

I had a similar problem because I develop outside my gopath...

Javier Segura
  • 658
  • 4
  • 13