How to return a 304 Not Modified response

I’m trying to return a 304 Not Modified response using Middy and Serverless.

I’ve written code in Middy middleware that sets the response statusCode to 304 and I can see this is executing when my code runs, but browsers always get a 200 response.

I’m guessing this has to do with API gateway configuration, but I’m not really sure what to do. 304 is not the default response, it’s not strictly an error, so what do I need to do to ensure that I can send a 304 all the way back to browser clients?