Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3231474
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T17:02:59+00:00 2026-05-17T17:02:59+00:00

I recently discovered that page object attributes in CherryPy are persistent between requests (and

  • 0

I recently discovered that page object attributes in CherryPy are persistent between requests (and between clients). So I’m wondering, would it make sense to store page output in such an attribute? Like this:

class Page:
    def default(self, pagenumber):
        if pagenumber not in self.validpages:
            return 'Page number not found'
        try:
            html = self.pageoutput[pagenumber]
        except KeyError:
            html = self.formatter(self.dbcall(pagenumber))
        return html
    default.exposed = True

    def formatter(self, data):
        html = # Formatting code here
        return html

    def dbcall(self, pagenumber):
        data = # Database lookup code here
        return data

I know CherryPy caches GET requests by default. In my tests, when an object attribute was part of the output and that attribute changed, CherryPy served the attribute’s new value. Does that mean the output was only partially cached?

To me this would be useful as long as you updated self.pageoutput every time you changed your database. The only difficulty I could imagine is if I wanted to display user-specific information. What do you think?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T17:03:00+00:00Added an answer on May 17, 2026 at 5:03 pm

    CherryPy does not cache GET requests by default; you have to explicitly turn on the caching tool as described in that documentation.

    To answer your first question, yes, it’s perfectly valid to store things like “pageoutput” that do not change between calls. However, there are a couple of caveats:

    1. HTTP caching is far better than what you can write on your own. So prefer that for whole responses.
    2. Therefore, use ad-hoc caching for parts of responses, such as templates and banners and such.
    3. Be very careful to design your storage to be safely concurrent. See effbot’s writeup on that subject for a start. In general, try to generate and store such values at application startup if feasible, instead of during a request; if you write such data in the main thread only at startup, it should be safely readable by multiple threads for each request. If you need such data to change as the application state progresses, you probably want to use a database or some other mechanism that has had hundreds of man-years of work to make it safely concurrent.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We recently discovered that the Google Maps API does not play nicely with SSL.
I only just recently discovered that Visual C++ 2008 (and perhaps earlier versions as
Recently I have discovered that my release executable (made with msvc++ express 2008) becomes
I've recently discovered the IsolatedStorage facilities in .net, and I'm wondering when I should
I've discovered this idiom recently, and I am wondering if there is something I
I recently discovered the genshi.builder module. It reminds me of Divmod Nevow's Stan module.
Having recently discovered this method of development, I'm finding it a rather nice methodology.
I recently discovered Erlang and am now working my way through a couple of
I recently discovered metaclasses in python. Basically a metaclass in python is a class
I was recently teaching myself Python and discovered the LBYL/EAFP idioms with regards to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.