Many sites use the hash (#) or shebang (#!) in their URLs for AJAX, and some end up breaking the *Back* button on your browser. The hash is important for letting Google index a link to a self-reloading page, but for pages that should not be indexed, there is a better way.
- http://foo.com/current.html
- Contains a POST-method link to "/link".
- http://foo.com/link
- On the server, the web framework interprets POST, computes new context, then redirects to the template "final.html", along with extra context.
- http://foo.com/final.html
- This would be the result of the template substitution.
- POST interpretation (the "controller") is separated from template substitution (the "view"). Most people instead use an if-clause in their controller.
- The web-designer can keep a simple redirect stub for the "link" page. That way, he can continue web-design in his static environment. He does not have to use a server or the intended framework.
- final.html is inherently secure, since none of the extra context is ever provided directly to that URL by the user.
I'm not sure why this pattern is not better known. Maybe I am overlooking some advantages of the alternatives.
No comments:
Post a Comment