Correct Caching For Nginx

This corrects the caching and also refactors to make changing caching settings in future by slightly refactoring the API controller.

The API can now we accessed over HTTP or HTTPS - I'm in two minds as to whether this is okay to allow the former.