Permanent redirection keeps hitting effective URL everytime

43 Views Asked by At

I have created two Rest API's in the backend (same webservice), one for the effective URL and other for the Redirected URL. I'm doing a 308 redirection here when user hits effective URL.

Scenario's

  1. When I mark the API's as POST or PATCH or DELETE,

    In Google chrome, my request always goes to the older url (effective) first and then get's redirected to the other one.

    I had breakpoints in both of the API's and validated that the request always hit's effective first for the above 3 HTTP methods. Also, I have hit the API like 20+ times via Ajax from the browser.

  2. When I mark the API's as GET,

    Only the first time, my request goes to the effective url and redirected to the other one. Subsequent call's via the same browser DIRECTLY takes me the other one until I clear the browser cache.

    I suppose this is expected behaviour of permanent redirection (301/308). Also, I'm aware of the difference between 301 and 308.

The major confusion is why the behaviour is not working as intended for NON-GET API's which are POST, PATCH, DELETE etc.

Chrome browser version: Version 88.0.4324.192 (Official Build) (x86_64)

0

There are 0 best solutions below