Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QUERY: Query body normalization is a bad idea #2896

Open
nicowilliams opened this issue Sep 16, 2024 · 14 comments
Open

QUERY: Query body normalization is a bad idea #2896

nicowilliams opened this issue Sep 16, 2024 · 14 comments

Comments

@nicowilliams
Copy link

See discussion in HN thread.

@nicowilliams
Copy link
Author

It might be a good idea to have a NORMALIZE method for requesting that the server normalize a QUERY body.

Basically, client-side normalization is going to be heavily dependent on the query MIME type. Do MIME registrations even provide normalization functions? Well, the registrations are fairly free-form, so that question is probably not relevant.

When JSON normalization has been discussed before it's proven to be an extremely tricky topic.

Server-side normalization, however, is much more likely to be possible, especially if the server parses a query into an AST, as then a canonical representation of the AST should be possible without having to specify any details in any RFCs.

@reschke
Copy link
Contributor

reschke commented Sep 17, 2024

Are you suggesting to add text about normalization? Precisely where?

@nicowilliams
Copy link
Author

OLD:

The cache key for a query (see Section 2 of [HTTP-CACHING]) MUST incorporate the request content. When doing so, caches SHOULD first normalize request content to remove semantically insignificant differences, thereby improving cache efficiency, by:

  • Removing content encoding(s)
  • Normalizing based upon knowledge of format conventions, as indicated by the any media type suffix in the request's Content-Type field (e.g., "+json")
  • Normalizing based upon knowledge of the semantics of the content itself, as indicated by the request's Content-Type field.

Note that any such normalization is performed solely for the purpose of generating a cache key; it does not change the request itself.

NEW:

The cache key for a query (see Section 2 of [HTTP-CACHING]) MUST incorporate the request body.

Caches SHOULD perform query normalization when possible when constructing cache keys. The extent to which query normalization can be performed, and how, is either a local implementation detail or a detail of the request body's MIME type, but note that at the time of this writing MIME type specifications and registrations do not typically include any normalization functions.

@reschke
Copy link
Contributor

reschke commented Sep 18, 2024

I disagree.

This is an implementation detail. A server can normalize based on how it uses the media type. No public spec is required here.

@nicowilliams
Copy link
Author

Yes, the server can normalize however it wants and it's a local detail for it. But caches need not be located in the server, and caches may not be able to normalize the same way as the servers.

@rafageist

This comment was marked as off-topic.

@reschke

This comment was marked as off-topic.

@rafageist

This comment was marked as off-topic.

@MikeBishop

This comment was marked as off-topic.

@rafageist

This comment was marked as off-topic.

@reschke

This comment was marked as off-topic.

@reschke
Copy link
Contributor

reschke commented Oct 17, 2024

@nicowilliams , I'd like to get this discussion resolved.

First of all, once a server responds with a Location field, a cache can simply cache this like GET to that URI, and the issue goes away. (right?)

I also don't think it would be good to discourage caches from normalizing. The three types of normalization seem to be pretty safe to me. If a server treats those type of normalisations differently, that would essentially be a very stupid thing for the server to do.

@reschke
Copy link
Contributor

reschke commented Oct 17, 2024

Also, would it be correct to say that this is not about normalization in general, but specifically to normalisations outside the origin server?

@mnot
Copy link
Member

mnot commented Nov 7, 2024

@nicowilliams it would be helpful to understand the motivation for the change. Pointing to a huge HN thread requires the reader to do an unreasonable amount of work - can you summarize?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

5 participants