-
Notifications
You must be signed in to change notification settings - Fork 9.3k
Docker swagger-ui container HTTP caching #5144
Copy link
Copy link
Closed
Description
Q&A (please complete the following information)
- OS: macOS 10.14.3
- Browser: Firefox
- Version: 64.0.2
- Method of installation: Docker
- Swagger-UI version: v3.20.5
- Swagger/OpenAPI version: OpenAPI 3.0
Content & configuration
$ docker run --rm -p 8888:8080 -e SWAGGER_JSON=/openapi.yaml -v $PWD/openapi.yaml:/openapi.yaml swaggerapi/swagger-uiDescribe the bug you're encountering
swagger-ui doesn't update on refresh after changing the openapi.yaml file outside the container. Displaying the old version of the OpenAPI document instead.
To reproduce...
Steps to reproduce the behavior:
- Start the swagger-ui Docker container with some
openapi.yamlfile.$ docker run --rm -p 8888:8080 -e SWAGGER_JSON=/openapi.yaml -v $PWD/openapi.yaml:/openapi.yaml swaggerapi/swagger-ui - Open swagger-ui in the browser.
- Modify the
openapi.yamlin some way. - Refresh the browser.
- The changes don't appear after refresh.
Expected behavior
The changes appear after refresh.
Additional context or thoughts
This is caused due to not specifying caching headers in the Nginx configuration. Simply adding an expires -1 to the configuration will resolve this, though it will make the browser re-validate the static swagger-ui files on each request. Without these headers the browsers use an unspecified heuristic caching behavior.
Reactions are currently unavailable