何时使用查询参数与矩阵参数?

时间:2022-01-10 21:20:58

Query parameters: http://example.com/apples?order=random&color=blue

查询参数:http://example.com/apples?order = random&color = blue

Matrix parameters: http://example.com/apples;order=random;color=blue

矩阵参数:http://example.com/apples;order=random;color=blue

  1. When should one use query parameters versus matrix parameters?
  2. 应该何时使用查询参数与矩阵参数?

  3. Why can matrix parameters be used in the middle of a URL but query parameters cannot? For example: http://example.com/apples;order=random;color=blue/2006/archive
  4. 为什么矩阵参数可以在URL的中间使用,但查询参数不能?例如:http://example.com/apples;order=random;color=blue/2006/archive

  5. If matrix parameters are a superset of query parameters, why not use them all the time?
  6. 如果矩阵参数是查询参数的超集,为什么不一直使用它们呢?

You can read more about matrix parameters here: http://www.w3.org/DesignIssues/MatrixURIs.html

您可以在此处阅读有关矩阵参数的更多信息:http://www.w3.org/DesignIssues/MatrixURIs.html

1 个解决方案

#1


The differences between Matrix parameters and Query Parameters are much more than just convention.

Matrix参数和查询参数之间的差异不仅仅是约定。

The main differences are:

主要区别是:

  • urls with query params won't have their response cached by intermediaries/proxies (at present)
  • 带有查询参数的网址不会被中介/代理缓存(目前)

  • matrix parameters may appear anywhere in path
  • 矩阵参数可以出现在路径的任何位置

  • calculating the relative uri is different
  • 计算相对uri是不同的

  • query params are generally abused to add new verbs instead of using existing methods on resources
  • 查询参数通常被滥用来添加新动词而不是在资源上使用现有方法

  • matrix parameters are not resources, they are aspects that help reference a resource in an information space that is difficult to represent within a hierarchy
  • 矩阵参数不是资源,它们是帮助引用难以在层次结构中表示的信息空间中的资源的方面

    I've written it up in more detail and with more references in Query vs. Matrix Parameters

    我已经更详细地编写了它,并在查询与矩阵参数中有更多参考

    #1


    The differences between Matrix parameters and Query Parameters are much more than just convention.

    Matrix参数和查询参数之间的差异不仅仅是约定。

    The main differences are:

    主要区别是:

  • urls with query params won't have their response cached by intermediaries/proxies (at present)
  • 带有查询参数的网址不会被中介/代理缓存(目前)

  • matrix parameters may appear anywhere in path
  • 矩阵参数可以出现在路径的任何位置

  • calculating the relative uri is different
  • 计算相对uri是不同的

  • query params are generally abused to add new verbs instead of using existing methods on resources
  • 查询参数通常被滥用来添加新动词而不是在资源上使用现有方法

  • matrix parameters are not resources, they are aspects that help reference a resource in an information space that is difficult to represent within a hierarchy
  • 矩阵参数不是资源,它们是帮助引用难以在层次结构中表示的信息空间中的资源的方面

    I've written it up in more detail and with more references in Query vs. Matrix Parameters

    我已经更详细地编写了它,并在查询与矩阵参数中有更多参考