inveniosoftware / invenio-records-rest

Invenio records REST API module.
https://invenio-records-rest.readthedocs.io
MIT License
4 stars 62 forks source link

browser caches all responses of same url regardless `Content-Type` #250

Open harunurhan opened 5 years ago

harunurhan commented 5 years ago

When you rely on Content-Type and different serializers of same record to serve different formats under same url, you might have caching issues on most of the browsers. Because invenio sets Last-Modified and Etag based on only record's version.

So it's likely that browser will reply with a different format to requests that has the same url. For example application/json instead of application/x-bibtex, because of same Etag and Last-Modified

Quick workaround would be remove Last-Modified and put Etag that includes both version and Content-Type.

equadon commented 4 years ago

After discussion with Lars

Current implementation

https://github.com/inveniosoftware/invenio-records-rest/pull/273

We cannot use an ETag which uses both the revision id and content-type with the current implementation since ETag are used both as a caching mechanism and for concurrency control. For caching it works:

  1. Create record
  2. GET xml
  3. GET json

will get you the right content and caching works.

However, if you do:

  1. Create record
  2. GET xml
  3. GET json
  4. PUT and update record

This probably will fail (please verify) and we need to find a solution that separates these concerns.

Suggestions on where to go next