博客
-
REST-ful URI design
What are the criteria for a good REST-ful URI?
I assert:
- Short (as possible). This makes them easy to write down or spell or remember.
- Hackable ‘up the tree’. The user should be able to remove the leaf path and get an expected page back. e.g. http://example.com/cars/alfa-romeos/gt you could remove the gt bit and expect to get back all the alfa-romeos.
- Meaningful. Describes the resource. I should have a hint at the type of resource I am looking at (a blog post, or a conversation). Ideally I would have a clue about the actual content of the URI (e.g. a uri like uri-design-essay)
- Predictable. Human-guessable. If your URLs are meaningful they may also be predictable. If your users understand them and can predict what a url for a given resource is then may be able to go ‘straight there’ without having to find a hyperlink on a page. If your URIs are predictable, then your developers will argue less over what should be used for new resource types.
- Help visualize the site structure. This helps make them more ‘predictable’.
- Readable.
- Nouns, not verbs.
- Query args (everything after the ?) are used on querying/searching resources (exclusively). They contain data the affects the query.
- Consistent. If you use extensions, do not use .html in one location and .htm in another. Consistent patterns make URIs more predictable.
- Stateless.
- Return a representation (e.g. XML or json) based on the request headers, like Accept and Accept-Language rather than a change in the URI.
- Tied to a resource. Permanent. The URI will continue to work while the resource exists, and despite the resource potentially changing over time.
- Report canonical URIs. If you have two different URIs for the same resource, ensure you put the canonical URL in the response.
- Follows the digging-deeper-path-and-backspace convention. URI path can be used like a backspace.
Some of these criteria pull against each other. For example, how can I make a meaningful-yet-short uri? URI-design rightly remains an art not a science. (更多…)
-
HTTP persistent connection
From Wikipedia,HTTP persistent connection, also called HTTP keep-alive, or HTTP connection reuse, is the idea of using the same TCPconnection to send and receive multiple HTTP requests/responses, as opposed to opening a new connection for every single request/response pair.
Contents
-
My fav Sublime Text 2 shortcuts
It’s a long time for me to write this blog, because I have got Evernote to noted everything I have learned, it is really very convenient.
These are the most common keyboard shortcuts that i use in Sublime Text 2 (WIN):
Ctrl + Shift + P – Commands list
Ctrl+P – Go to anything. I just hit Ctrl+P and type parts of files I want to open – huge time saver.
Ctrl + Space – Auto completion.
Alt + 1, 2, 3, 4, … – Switch between open files’ tabs. Not to waste your time grabbing a mouse, and clicking on a tab.
Ctrl + PgUp/PgDn – Cicles throught the open files
Ctrl + click somewhere in your code – multiplies your caret, so you can simultaneously enter, delete, overwrite your code. Hitting Esc will exit this function. (更多…)
-
钱
钱,赤裸裸的钱。
没有钱,没有前。
有时候,即使那么不在乎它。
这是一个花钱如流水的季节,即使有一些是那么的不情愿。
生活该这样,生活不该这样。