Re: [go-nuts] Http Handler to produce static content

2019-05-20 Thread Amnon Baron Cohen
When web-apps are implemented in scripting languages which suffer from poor performance, it is common practice to proxy them behind a "real" web server such as nginx, and offload SSL termination, caching, handling of static components, etc to it. In Go http.ListenAndServe is an industrial strengt

Re: [go-nuts] Http Handler to produce static content

2019-05-20 Thread Tyler Compton
> Sorry I don't quite understand -- my go application IS my webserver. > This is a topic that has confused me in the past. In the simple case where you build a Go executable and get requests from it directly, your Go application *is* your web server. However, it's common in industry to put a syste

Re: [go-nuts] Http Handler to produce static content

2019-05-19 Thread Tong Sun
Thanks a lot Tamás! That's very clear & helpful! On Sun, May 19, 2019 at 10:54 AM Tamás Gulácsi wrote: > > ETag and Last-Modified are just to allow the browser to decide with a HEAD > request, whether GET the whole resource. -- You received this message because you are subscribed to the Google

Re: [go-nuts] Http Handler to produce static content

2019-05-19 Thread satyendra singh
No what I have said is the enterprise or standard way of doing it.the functionality you are looking for is not specific to any programming language. It is with the http headrers which is standard across all platforms. But if you really want to do in your app you need to cache-control header in your

Re: [go-nuts] Http Handler to produce static content

2019-05-19 Thread satyendra singh
Hi Tong, You can use a webserver between browser and your go application which will take care of header modification for browser caching. Thanks and regards, Satyendra On Sun, 19 May, 2019, 7:26 PM Tong Sun, wrote: > Hi, > > How to have http.Handle / http.HandleFunc to produce static content th

[go-nuts] Http Handler to produce static content

2019-05-19 Thread Tamás Gulácsi
ETag and Last-Modified are just to allow the browser to decide with a HEAD request, whether GET the whole resource. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email

[go-nuts] Http Handler to produce static content

2019-05-19 Thread Tamás Gulácsi
Yust set the headers you want, with w.Header().Set, before any Write. For example Set("Cache-Control", "public, max-age=31536000") -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, s

Re: [go-nuts] Http Handler to produce static content

2019-05-19 Thread Tong Sun
Sorry I don't quite understand -- my go application IS my webserver. Are you saying Go net/http is not capable of doing what I'm asking? On Sun, May 19, 2019 at 9:59 AM satyendra singh wrote: > > Hi Tong, > You can use a webserver between browser and your go application which will > take care o

[go-nuts] Http Handler to produce static content

2019-05-19 Thread Tong Sun
Hi, How to have http.Handle / http.HandleFunc to produce static content that browser will use their caches without downloading every time? For a simplest http.HandleFunc, like the following, func sayHello(w http.ResponseWriter, r *http.Request) { message := "Hello " w.Write([]byte(mes