Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When to use query parameters versus matrix parameters?

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

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

  1. When should one use query parameters versus matrix parameters?
  2. 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
  3. If matrix parameters are a superset of query parameters, why not use them all the time?

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

like image 384
Gili Avatar asked Dec 31 '08 00:12

Gili


People also ask

What is the difference between path and query parameters when should you use them?

URI parameter (Path Param) is basically used to identify a specific resource or resources whereas Query Parameter is used to sort/filter those resources. Let's consider an example where you want identify the employee on the basis of employeeID, and in that case, you will be using the URI param.

What is the difference between a query parameter and a route parameter?

The key difference between query parameters and route parameters is that route parameters are essential to determining route, whereas query parameters are optional.

Why do we use query parameters?

Query parameters are a defined set of parameters attached to the end of a url. They are extensions of the URL that are used to help define specific content or actions based on the data being passed.

What are matrix parameters?

The Parameter Matrices, or Parameter Index Matrices (PIM), define the set of real parameters, and allow constraints to be placed on the real parameter estimates. There is a parameter matrix for each parameter in each group, with each parameter matrix shown in its own window.


1 Answers

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

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
  • 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

    like image 152
    bdargan Avatar answered Oct 19 '22 03:10

    bdargan