pythonmongodbhttphttp-headersflask-restx

HTTP HEAD for custom header vs partial object fetching


I wish to perform a conditional GET request for a document depending on the value for a particular attribute of that document. I came across two ways that would help me do that.

  1. Include this attribute as a custom header for the GET method and use the HEAD request to get the headers & determine whether to actually make the GET request.

  2. Use partial object fetching for the GET request using fields mask in flask-restplus/flask-restx.

I am not sure if either of the approaches is the best way to solve the problem at hand.

Is using custom headers a common practice? Are there any red flags that come with it? (I came across one so answer that mentioned that some firewalls filter out custom headers)

Does partial object fetching actually have any tangible benefits? How do the operations differ behind the scenes?


Solution

  • Recently found out about an HTTP concept called conditional requests. It is similar in idea to the first approach I had in mind, only that it's even better. The headers are standard ones and the error handling is taken care of.