Show global 404 if part fail to load content

Enonic version: 6.15.0

I know this is already posted in Throw 404 from a part, but I would like to ask if there are any other solution today?

We load content from an external service, and we want to show a global 404 page if the part(s) fails to load the content.

Right now we’re thinking about doing the load-logic as part of the page controller and caching the content via lib-cache so that the parts don’t need to load the content again.

I found out that I could use response filters to handle this.

The part returns something like { headers: { status: 404 } }, and the response filter looks for this and acts as a error handler (I’m reusing some functions so that I don’t have to update multiple places when I update error handling).