POST requests are generally not cached, but you can force it to be
cached using the Cache-Control and Expires headers. However, I've
never tried this so I don't know if the browser will still show the
form submission dialog (it may need to resend the form data to check
to see if the document has changed since last requested). It probably
won't, but I would still strongly advise against this.

A search request is generally an idempotent operation (multiple
requests do not have any side-effects), which is precisely what the
GET request is designed for. There's no reason to use POST in this
case. Cake has a perfectly good way of hiding ugly URL-encoding using
its REST-style routing patterns, e.g.:

http://yoursite.com/pages/search/foo/bar/foo2/bar2/...

You can also use named parameters to make the search URL more
readable, e.g.:

http://yoursite.com/products/search/q:paegan/artist:acid+bath/category:t-shirt

Unless you have a ton of search options, I see no reason to use POST.
And even if you use POST and generate shorter/cleaner URL--what's the
point? What will that clean URL achieve? The user can't bookmark it.
They can't link a friend to it. They can't do anything with it.

A happy compromise would be to do what a lot of forums do, and cache
each search server-side. Then when the user performs a search (with
either POST or GET), they get redirected to the cached search result,
which might be something like:

http://yoursite.com/search/paegan+terrorism+tactics/f83e3a4b389c6b

That will decrease your server load, allow you to use a POST form, and
still allow the user to bookmark/link the search results (at least for
a time).

On Jun 4, 10:40 am, Ed Propsner <crotchf...@gmail.com> wrote:
> I was checking out the book on complex queries and not really finding what
> I'm looking for.
>
> I'm trying to create a query that covers both a basic and advanced search.
> The form may be submitting all or just some of the options available on the
> page depending on what the user chooses.
>
> Once the form has been submitted clicking any one of the query results would
> navigate the user away from the 'results page'.
>
> To avoid getting hit with the "form submission" dialogue when the users
> clicks the back button to return to the search results page
> and to cover the 'conditional query' ... I used to use a combo of $_GET and
> if(isset.
>
> ie:
>
> $query= " SELECT something FROM somewhere WHERE etc. etc. etc. AND ";
>
>    if (isset($_GET['some_value']) && $_GET['some_value'] != '' )
>   {
> $value = $_GET['some_value'];
> $query .= "AND  something = '".addslashes($value)."'";
>   }
>
> And so on.
>
> I'm not familiar with using cache for anything. To avoid using get and the
> ugly urls would I be able to use post and cache the results also avoiding
> the "form submission" dialogue when returning to the results page?
>
> Also, what is the best approach to setting up a 'conditional' query similar
> to what I posted above?
>
> I'll spend some more time digging through the book and experimenting if
> someone can point me in the right direction.
>
> Thanks,
>
> - Ed

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to