HTML and CSS Reference
In-Depth Information
Replace Safe POST with GET
Redesign safe operations so that they are accessed via GET rather than POST.
Code View:
<form method="post" action="listarticles.php">
<p><label>Display
<input name="number" value="10" type="text" />
articles</label></p>
<p><label>Sort by: <select name="sort">
<option value="Reverse">Most recent first</option>
<option value="Forward">Publication order</option>
<option value="Author">By author</option>
<option value="Title">By title</option>
</select></label></p>
<p><input type="submit" value="List articles" /></p>
</form>
<form method="get" action="listarticles.php">
<p><label>Display
<input name="number" value="10" type="text" />
articles</label></p>
<p><label>Sort by: <select name="sort">
<option value="Reverse">Most recent first</option>
<option value="Forward">Publication order</option>
<option value="Author">By author</option>
<option value="Title">By title</option>
</select></label></p>
<p><input type="submit" value="List articles" /></p>
</form>
Motivation
URLs that can be accessed with GET can be linked to, spidered, bookmarked, prefetched, cached, printed in
topics, painted on the sides of buildings, and more. GET URLs enable the use of the back button. A GET
operation is just overall friendlier to the user than a POST operation.
GET URLs are also friendlier to search engines, and they improve your site's search engine ranking. POST-only
URLs are effectively invisible to spiders and search engines. Other sites and people can link to your GET URLs,
which improves your traffic directly when people follow the links and indirectly when search engines notice the
links and boost your page rank accordingly.
Finally, representations of GET URLs can be cached, which dramatically improves both client and server
performance.
Potential Trade-offs
Done right, none. However, you do need to be careful that your operations are really free of side effects. Using
Search WWH ::




Custom Search