I'm late to the conversation but if I'm understanding, I did something like 
this last year. 

I built a reporting front end on MySQL, served by web.py. Basically, every 
report had a distinct URL, and the server would perform the SQL and generate 
the page.  I wanted to deliver a cached report until the underlying data 
changed. 

So, I actually did two things: first, for data that was only updated once a 
week, I built a daemon process that created static HTML files.  In my app I 
made sure to append a random number to any links to this report to bust the 
browser caching.  So, the user would get a fresh page from the web server each 
request, but it was a straight file serve so very fast.

Second, for reports that might update randomly, I made a compromise. Saved a 
cookie with a timestamp on the browser, and used that on the server to only do 
the db query once an hour.  Put a button on the page so the user could do a 
"live refresh" if they felt the data was stale.  This translated to much faster 
pages overall, with the occasional lag once an hour. 

Not sure if any of this helps at all.

Finally, as a best practice note regarding serving SQL query results via a web 
server - I *never* build a report with a live query if there's any chance the 
SQL will take more than 3 seconds to complete. Waiting on a server translates 
to user unhappiness.  In cases where queries might be long (I've had some 
oracle queries that run for several hours!), I always build a daemon process 
that aggregates the data into flat and fast summary tables that can be quickly 
served.

S

On Jun 26, 2013, at 8:54 AM, Jox <[email protected]> wrote:

> huh.... I'm not sure if web server deal with issue like this. I think this is 
> a application layer issue. I'm trying to figure out how to do it with 
> javascript. 
> but thanks all the same!! Tomas
> 
> On Wednesday, June 26, 2013 9:49:30 PM UTC+9, Tomas Schertel wrote:
>> 
>> On Tuesday, 25 June 2013 18:05:46 UTC-3, Jox wrote:
>>> 
>>> I've read the page. So it compiles my templates to python byte code. Does 
>>> that mean I can load templates faster?
>>> But it seems I still have to query database to get data. 
>>> 
>>> The website I'm building is my learn-by-do project. It's just a forum 
>>> running on my linux server or google app engine 
>>> which my friends and I can play around on it. I know querying database when 
>>> a request comes in is easy and good 
>>> enough. I've already implemented serving pages that querying database a lot 
>>> and render pages with templates every 
>>> time. I just want to know how could I implement a basic caching mechanism, 
>>> not a big caching system which has 
>>> caching strategies and complex algorithms or stuff like that. Just a simple 
>>> and straight-forward one.
>> 
>> Maybe you should look for a webserver that does it.
>> Apache? NGINX?
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "web.py" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/webpy.
> For more options, visit https://groups.google.com/groups/opt_out.
>  
>  

-- 
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to