Help With Using ETAGS

2015-06-23 Thread Nikunj Badjatya
Hello All,

What is the difference between setting ETAGS  (USE_ETAGS=True)in django 
settings file vs setting ETAGS in nginx configuration ? 

Do one need to set at both the places or just one place is sufficient ?

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/dc5fb7c2-3b3a-4189-a7a8-1f77a89bae7a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Using etags for backend caching

2012-12-08 Thread Tom Eastman

Hey guys,

My project makes pretty heavy use of etags for browser-level caching, 
but I'd like to go one step further and be able to cache pages on the 
backend keyed by the page's etag.


As far as I can tell, none of the current built-in caching 
middleware/decorators or conditional processing does this, but I don't 
think it will be terribly hard to implement.


The logic would look something like this:

etag = calculate_etag(request)
if etag in cache:
return cache.get(etag)
else:
response = view(request, ...)
cache.set(etag, response)
return response

Does this seem feasible? Are there any major problems I'm missing? Has 
someone already done it?


If no-one's done it before, and you think it sounds super useful, should 
I write a generic enough version that I can put online for people to use?


Thanks for any input you can give.

Cheers!

Tom


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



About conditional view processing: ETags

2009-10-04 Thread Torsten Bronger

Hallöchen!

So far, I've used only the "last-modified" function for conditional
view processing, which worked nicely.

Now, I have a view which may switch between certain states, which
makes "last-modified" less useful.  I implemented an ETags function
for the "conditional" decorator but it didn't help at all: Opera
nevers sends "IF-NONE-MATCH", and Firefox sends only the
"IF-NONE-MATCH" of the most recent version of the page, which is no
more useful than "last-modified" alone.

Do I have to switch on further header tags in oder to trigger useful
browser behaviour in this case?  Or should it be enough to set the
ETag function in @conditional(...)?

At the moment, I wonder why one wants to use ETags at all ...

Tschö,
Torsten.

-- 
Torsten Bronger, aquisgrana, europa vetus
   Jabber ID: torsten.bron...@jabber.rwth-aachen.de
  or http://bronger-jmp.appspot.com


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



Re: [django] Re: Etags

2009-02-15 Thread Ricardo Newbery


On Feb 15, 2009, at 3:28 PM, Malcolm Tredinnick wrote:

>
> On Sun, 2009-02-15 at 08:30 -0800, mermer wrote:
>> OK - I've found the problem.  I'm using Firefox (Version 3.06) but  
>> the
>> problem is actually with Firebug, which I've been using to view the
>> headers.
>>
>> With Firebug disabled, it works fine (viewing the headers through
>> another app).
>
> Realise that a browser isn't *required* to send if-none-match. So this
> isn't really a bug in Firebug. It's possibly deliberately not sending
> the header to ensure that it sees the full interaction each time,  
> rather
> than a 304 response.
>
> Also, you probably want to make sure you're also handling
> if-modified-since, as that's also used to check for "liveness".
>
> Regards,
> Malcolm


No sorry, this is definitely a Firebug bug.

http://code.google.com/p/fbug/issues/detail?id=1274

Ric




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



Re: Etags

2009-02-15 Thread Malcolm Tredinnick

On Sun, 2009-02-15 at 08:30 -0800, mermer wrote:
> OK - I've found the problem.  I'm using Firefox (Version 3.06) but the
> problem is actually with Firebug, which I've been using to view the
> headers.
> 
> With Firebug disabled, it works fine (viewing the headers through
> another app).

Realise that a browser isn't *required* to send if-none-match. So this
isn't really a bug in Firebug. It's possibly deliberately not sending
the header to ensure that it sees the full interaction each time, rather
than a 304 response.

Also, you probably want to make sure you're also handling
if-modified-since, as that's also used to check for "liveness".

Regards,
Malcolm


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



Re: Etags

2009-02-15 Thread mermer

OK - I've found the problem.  I'm using Firefox (Version 3.06) but the
problem is actually with Firebug, which I've been using to view the
headers.

With Firebug disabled, it works fine (viewing the headers through
another app).



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



Re: Etags

2009-02-15 Thread Karen Tracey
On Sun, Feb 15, 2009 at 5:59 AM, mermer <merme...@googlemail.com> wrote:

>
> I am trying to get Etags working in Django - so that if a page has not
> been updated (and the client has already seen the page) it is returned
> by the client's browser rather than rendered by django.
>
> The code below is proof of concept.   However, it only partially
> works, and that's why I'm asking for help.
>
> When the client first connects the code correctly renders the page and
> returns an ETAG header.
>
> On the next request, the browser correctly sends the "If None Mach"
> request header with the ETAG details. The code correctly returns the
> 304 respose and the client displays the page from the browser's
> caache.
>
> So far so good.
>
> However, on the third request, it seems that the browser does not send
> a "If-None_match" request header, so the etag is not found and the
> whole page re-renders from the server.
>
> Is there something else I need to configure?  Or something I am doing
> wrong?
>
>
My immediate reaction is it sounds like the browser is misbehaving, since it
is the piece that drops the ball and does not send the if-none-match
header.  You haven't said anything about the browser -- which browser is it?
Is this behavior consistent across a range of browsers or specific to only
one?

Another thing to check would be how Django's built-in etag handling behaves,
see:

http://docs.djangoproject.com/en/dev/ref/settings/#use-etags

If you see a difference with the built-in etag handling and your code (I am
assuming you are writing your own version to do something a bit more
sophisticated than what the built-in middleware bit can do?) then I'd
suspect there's something missing from what your code is doing, otherwise
again I'd be looking in more detail at the browser specifics.

Karen

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



Etags

2009-02-15 Thread mermer

I am trying to get Etags working in Django - so that if a page has not
been updated (and the client has already seen the page) it is returned
by the client's browser rather than rendered by django.

The code below is proof of concept.   However, it only partially
works, and that's why I'm asking for help.

When the client first connects the code correctly renders the page and
returns an ETAG header.

On the next request, the browser correctly sends the "If None Mach"
request header with the ETAG details. The code correctly returns the
304 respose and the client displays the page from the browser's
caache.

So far so good.

However, on the third request, it seems that the browser does not send
a "If-None_match" request header, so the etag is not found and the
whole page re-renders from the server.

Is there something else I need to configure?  Or something I am doing
wrong?


Cheers

MerMer


def etag_test(request):

etag = "TestEtag12345"
if etag == request.META.get("HTTP_IF_NONE_MATCH"): # Check to see
if request has matching etag
return http.HttpResponseNotModified() # if etag matches  send
a 304 reponse, so browser uses client cache


html="This is a test of ETAG"

   #Finally, add in the ETag to the new response we're returning.
response = http.HttpResponse(html)
response["Etag"] = etag  # add Etag header to respone

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



Re: using Etags or http response code 304 (not modified)

2008-11-11 Thread Malcolm Tredinnick


On Tue, 2008-11-11 at 05:08 -0800, [EMAIL PROTECTED] wrote:
> hi Karen,
> 
> thanks for the response..I havent verified if the client is sending
> the If-none-match header. Essentially my project uses rss feeds. and i
> redirect them to feedburner. I dont want my site to keep sending http
> 200 along with the entire feed if no udpates have been made to the
> feed. i can see the etag being sent in the http response. but when i
> see the http access logs, the next time that the feedburner crawler
> comes to fetch, my site sends out a http 200.

The real question is whether it also sends out the same ETag value as
the previous time. If not, then that's the reason for the 200 response:"
something has changed. If it is sending the same ETag value, then
something is incorrect in your setup that needs to be debugged a bit
further.

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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-users?hl=en
-~--~~~~--~~--~--~---



Re: using Etags or http response code 304 (not modified)

2008-11-10 Thread Karen Tracey
On Mon, Nov 10, 2008 at 4:14 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:

>
> I've tried using the USE_ETAGS=true in my project settings and even
> tried using the ConditionalGet Middleware. However, whenever an http
> request is made to my page, it always seems to return a http code 200
> along with the entire data.
>
> how / what do I need to do so that a http 304 is issued if the data
> hasnt been modified ?
>
> do i need to do do anything within my view to issue the http 304 ?
>

No, I just set USE_ETAGS=True in my settings.py and (since I already had
CommonMiddleware specified) now I see my server return 304 for unchanged
pages.  Presumably you're using something to look at the headers in the
requests/responses -- can you see the Etag in the responses?  Is your client
sending If-None-Match when it then requests the same page?

Karen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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-users?hl=en
-~--~~~~--~~--~--~---



using Etags or http response code 304 (not modified)

2008-11-10 Thread [EMAIL PROTECTED]

I've tried using the USE_ETAGS=true in my project settings and even
tried using the ConditionalGet Middleware. However, whenever an http
request is made to my page, it always seems to return a http code 200
along with the entire data.

how / what do I need to do so that a http 304 is issued if the data
hasnt been modified ?

do i need to do do anything within my view to issue the http 304 ?

thnx.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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-users?hl=en
-~--~~~~--~~--~--~---



Using ETags with Django

2008-08-19 Thread Jon Brisbin

Are any of you using ETags with Django? I'm wondering what the easiest  
solution for determining whether I need to send back a 304 is. I have  
last-modified timestamps on my models, so I could conceivably query  
those and match them against the If-Modified-Since header. It seems  
like I'd be doing two queries, though. Once for the latest timestamp  
and again for the real objects.

The other alternative seems to be to create a model specifically for  
determining whether result sets have been dirtied or not. I'd have to  
make sure my update routines updated this object whenever a model got  
updated that would dirty a result set. Although new content will be  
added (hopefully) frequently, I'm not sure there will be that much  
changing once it's been added. I definitely want to reorder the list  
of content based on weighting a random ordering, so for some views it  
will be difficult to rely on ETags for caching.

Since Django encourages the use of clean urls, though, it seems like I  
should be able to use ETags with my models, especially when getting  
the detail for a particular instance. How would I attack this in a  
reasonably clean (i.e. able to be reused with any views I want ETags  
for...but not *every* view) way? I'd like hear how others have solved  
this before I spend a lot of time hitting dead ends.

Thanks!

Jon Brisbin
http://jbrisbin.com




--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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-users?hl=en
-~--~~~~--~~--~--~---