nitrogen / simple_bridge

A simple, standardized interface library to Erlang HTTP Servers.
MIT License
112 stars 76 forks source link

build_response forces Expires header? #20

Closed davidw closed 11 years ago

davidw commented 11 years ago

Hi,

I've been encountering some trouble with static content being cached in ChicagoBoss ( https://github.com/evanmiller/ChicagoBoss/issues/229 ) and part of my digging led me to this code, in which the Expires header is set, whether I like it or not:

        ExpireDate = simple_bridge_util:expires(years, 10),
        %% Create the response telling Mochiweb to serve the file...
        Headers = [{"Expires", ExpireDate}, {"Cache-Control", "no-cache"}],

Shouldn't this be set somewhere else, rather than in code that's supposed to just make two other systems talk to one another?

Thank you

choptastic commented 11 years ago

This is definitely something that should be moved into an application env var. I agree.

davidw commented 11 years ago

Looking at things more, I see that, indeed, in build_response, if it's a file, the headers just get thrown out completely! Is there a reason not to share the header munging code between the two code paths, and use Headers2 in both of them?

choptastic commented 11 years ago

You're definitely right. It's not done currently because the default behavior for Nitrogen is if it's a static file, it immediately passes the buck to simple_bridge to dole out to the webserver without doing anything. I can definitely see the value, however, in honoring any headers that are set prior to calling build_response.

choptastic commented 11 years ago

This is merged. Thanks.