Thank you for this information. Shall I use a jquery.ajax-call or can I use
the LOAD-helper?


2014-08-07 11:24 GMT+02:00 Niphlod <[email protected]>:

> if you trigger an ajax request, if it's a GET (an idempotent method) you
> may avoid reloading the page and get back a 304....................but it's
> not handled automatically by web2py unless the content is static.
>
>
> On Thursday, August 7, 2014 7:52:30 AM UTC+2, mweissen wrote:
>>
>> Dave told me that my explanation was not clear. Let me try it in other
>> words. What I want is a program which periodically reloads a page (I think
>> using LOAD is the best way), but only if I allow it.
>>
>> My idea was that the header parts "Last-Modified" and/or "ETag" could do
>> the job. Therefore I wrote the program in two steps:
>>
>> (1) A controller without any response header modification. It shows the
>> actual time and reloads once a second - everything is fine.
>>
>> The functions:
>>
>> def mytime():
>>     jetzt=str(request.now)[:19]
>>     return dict(jetzt=jetzt)
>>
>> def init():
>>     return dict()
>>
>> -------------------------
>>
>> The views:
>>
>> mytime.load:
>> {{=jetzt}}
>>
>> init.html:
>> {{extend 'layout.html'}}
>> {{=LOAD(f="mytime.load", ajax=True, timeout=1000, times="infinity")}}
>>
>>
>>
>> (2) Now I want to simulate an unchanged page. Anthony wrote on
>> http://stackoverflow.com/questions/14515313/how-to-
>> modify-web2py-download-function-to-return-304-not-modified-in-case-the
>> how to change the header. I add the response.headers-lines with a *constant
>> *"Last-Modified" time and/or a *constant *"ETag" (I think every value is
>> allowed here). My hope has been that these modifications *would prevent
>> a reload* of the page. If this would be correct I would always see the
>> same time. But it did not work, regardless of the header modifications the
>> page reloads again once a second.
>>
>> def mytime():
>>     jetzt=str(request.now)[:19]
>>     mtime = "Mi, 06 Aug 2014 08:11:00 GMT" # always the same time!
>>
>> *response.headers['Last-Modified'] = mtime*
>>
>> *    response.headers['Pragma'] = 'cache'    response.headers['Cache-*
>> *Control'] = 'private'     response.headers['ETag'] = "123" # any value,
>> constant*
>>     return dict(jetzt=jetzt)
>>
>>
>> My primary problem is: the LOAD helper (or an other command?) asks the
>> server periodically if there is a new content - and the server should
>> reload the page under program control.
>>
>> Is it possible to solve it using the response headers?
>>
>> The purpose of the request.now call is only to show whether the page
>> reloads or not.
>>
>> Regards, Martin
>>
>> -
>>
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to