Skip to content


Query vs. Matrix Params or Path Params

I've come across a few posts about Matrix Parameters recently and there is a lot of misunderstanding.

There are several old posts that discuss and describe these things:

I've summarised what I think is important:

Tip: If you're not sure if you should use them then don't.

Matrix parameters are used with

Caching Issues

Intermediaries (proxies) won't cache any url with a query parameter in the url
  • this is because in the early days of the web, they didn't trust the Cache control information from dynamically generated pages.
  • Freshness and Validation information are very important pieces of information and the proxy admins took a cautious stance and didn't cache any of it.

As the web has matured the views of devs/admins are changing, the new versions of Squid will default to cache any urls with query parameters

Obviously this could have a very large impact, I've heard google maps image tiles had this issue with some proxies at one time.

Relative URI calculations

Relative URIs have different affects, as relatives URLs are determined by appending to the Base URI. For Query Parameter requests they are stripped from the Base.

For those still interested I would recommend checking out the following in addition to the RFC-2616 of course.

Posted in RESTful, Web. Tagged with , , .

6 Responses

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

  1. good stuff! thanks for putting all of this info together.

  2. Hey, thanks for the shoutout.

  3. James Collins said

    Hi Brett, the content for this post seems to have disappeared. I would be very grateful if I could see a copy. We’re having a discussion on my firm on query parameters vs. matrix parameters in RESTful service URIs. Thanks!

  4. admin said

    site5 moved hosts recently.

    here is a dump of the raw content in the mean time.

    I’ve come across a few posts about Matrix Parameters recently and there is a lot of misunderstanding.

    There are several old posts that discuss and describe these things:

    * `Query Strings Considered Harmful `_
    * `w3c MatrixURIs `_

    I’ve summarised what I think is important:
    – 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
    – much more than uri convention

    – 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

    **Tip: If you’re not sure if you should use them then don’t.**

    Matrix parameters are used with
    * `YUI paging widgets `_
    * `RoR`_ /some/resource/id;edit
    * J2ee fallsback to ;jsessionid=xxx when no cookies can be set.
    * `Jersey (JAX-RS RefImpl) has good support `_

    .. _RoR: http://rails.org

    .. _won’t have their response cached by intermediaries/proxies (at present):

    Caching Issues
    ~~~~~~~~~~~~~~~

    Intermediaries (proxies) won’t cache any url with a query parameter in the url
    * this is because in the early days of the web, they didn’t trust the Cache control information from dynamically generated pages.
    * Freshness and Validation information are very important pieces of information and the proxy admins took a cautious stance and didn’t cache any of it.

    As the web has matured the views of devs/admins are changing, the new versions of Squid will default to cache any urls with query parameters

    Obviously this could have a very large impact, I’ve heard google maps image tiles had this issue with some proxies at one time.

    .. _calculating the relative uri:

    Relative URI calculations
    ~~~~~~~~~~~~~~~~~~~~~~~~~

    Relative URIs have different affects, as relatives URLs are determined by appending to the Base URI. For Query Parameter requests they are stripped from the Base.

    For those still interested I would recommend checking out the following in addition to the `RFC-2616 `_ of course.

    * `the matrix revisited `_
    * `PathsAndQueryStrings `_
    * `http url path parameter syntax `_
    * `Building URIs `_

  5. James Collins said

    Thanks, Brett!

  6. Bibin sunny said

    cool man …a new piece of information

Some HTML is OK

(required)

(required, but never shared)

or, reply to this post via trackback.


Twitter links powered by Tweet This v1.8.1, a WordPress plugin for Twitter.