Hash params vs url params, when to use which?

Solution 1:

Hash params are useful for single page javascript applications, it allows javascript to present the user with a sharable url for state of the application. This is preferred because if you have a single page javascript application and users navigate and load more content via ajax and share the url, without the hash or a push state modification the person receiving the content would get the homepage or starting state. Hash params can be amended easily and read by javascript without reloading the page.

Hash parameters are usually only used on the client side, hash params wont be passed to the server... so they are only useful for parameterization to the client.

/users#!/13

would load the user index page and then javascript could read the hash

window.location.hash and pass it through some sort of client side router and make an appropriate ajax request and possibly load the user show template and push it to the dom.

Url params and url path are somewhat interchangeable. People usually use url path for describing restful resources such as

/users/[:id] => /users/13 => /users?id=13
/users/:id/posts => /users/13/posts
/users/:user_id/posts/:id => /users/13/posts/22
etc......

@Walter Tross, made a good point from an SEO point of view. Slugged urls or "URL Params" are more indexable by crawlers and tend to rank higher.

For params that do not fit in a resourceful route we send them as params

/users?sort=user_name&order=asc