Hi!

Currently query parameters are ignored when using the cache decorator
for views (only the path segment [3] is used to determine the key).
This impacts performance for Django sites where query parameters are
used for filtering and sorting of lists of items (a common use case).

I found an old discussion on this list [1] where Adrian Holovaty asked:

"The remaining question is: What's the behavior if vary_on_get() isn't
specified for a particular view? Do we cache everything (including
separate cache entries for any combination of different GET
parameters) or cache nothing (current behavior)?"

In ticket #4992 [2] I have proposed the following:

URL:s should be treated as opaque by the caching system. Consider
these sample URL:s

Request A: example.com/list/
Request B: example.com/list/?a=1&b=2
Request C: example.com/list/?b=2&a=1

If URL:s are treated as opaque, requesting A, B and C would create
three separate items in the cache. This would be the default behaviour
for the following:

@cache_page(60 * 15)
def list(request):
    ...

More fine grained cache behaviour could be specified with a
vary_by_param decorator like this:

@cache_page(60 * 15)
@vary_by_param("a", "b")
def list(request):
    ...

Requesting B and C above would create one item in the cache, i.e.
ordering is not important.

An idea would be to exclude the fragment part [3] from impacting the
cache as it is unlikely that developers rely on that for server side
behaviour (it is more likely used to give focus to a particular item
in the rendered HTML).

Kind regards,

Peter Krantz

[1]: http://groups.google.com/group/django-developers/msg/54d5750440d4bc93
[2]: http://code.djangoproject.com/ticket/4992#comment:9
[3]: http://labs.apache.org/webarch/uri/rfc/rfc3986.html#components

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to