ng-token-auth icon indicating copy to clipboard operation
ng-token-auth copied to clipboard

Why you added fixed "If-Modified-Since" header?

Open dobryakov opened this issue 9 years ago • 5 comments

$httpProvider.defaults.headers[method]['If-Modified-Since'] = 'Mon, 26 Jul 1997 05:00:00 GMT'

Why? What this date means? Is it your birthday?

Do you understand how it affects on HTTP caching? You have totally broken all browser caching mechanism. The browser should have an ability to decive what to cache or not, and the server can answer with 200 (content) or 304 (without content) depends on real datetime in this header.

dobryakov avatar Sep 22 '16 09:09 dobryakov

Found here https://github.com/lynndylanhurley/ng-token-auth/blob/058bc2bb56ee455c40a53485c2070a8d7df6db2d/src/ng-token-auth.coffee

dobryakov avatar Sep 22 '16 09:09 dobryakov

Solution for globally disable this behaviour:

app/scripts/app.coffee

httpMethods = ['get', 'post', 'put', 'patch', 'delete']
angular.forEach(httpMethods, (method) ->
  $httpProvider.defaults.headers[method] ?= {}
  delete $httpProvider.defaults.headers[method]["If-Modified-Since"]
)

dobryakov avatar Sep 22 '16 10:09 dobryakov

#324

svlapin avatar Sep 22 '16 13:09 svlapin

#340

merqlove avatar Dec 13 '16 10:12 merqlove

holy moly, this cost me so much brain damage actually. this lets you run into wall when you do any other requests than to the api you are authenticated with.

mxmzb avatar Feb 01 '17 18:02 mxmzb