Pyplate's content directory contains a directory structure that mirrors the site's category structure. Every time a category is created, a corresponding directory is created in the content directory tree, and in the web root directory.
Posts are stored as HTML files in the appropriate dirctory in the content directory tree. These files only contain the HTML code for each post, without any of the code for the rest of the page. When a page is served dynamically, Pyplate builds a page and embeds the contents of one or more post files in the page.
When a page is requested by a user, the domain name is stripped from the requested URL, leaving a relative path. For example, a request for a page at http://example.com/foo/bar/bletch.html gives a relative path of /foo/bar/bletch.html. Pyplate uses the relative path and translates it to an absolute path by appending it to /usr/share/pyplate/content. The file containing the post can be found at /usr/share/pyplate/content/foo/bar/bletch.html.
When Pyplate is installed, Apache's default web root directory, /var/www, is moved to /var/www2. In it's place, the Pyplate installation script creates a file system link from /var/www to /usr/share/pyplate/webroot. Files and directories in Pyplate's webroot directory can be accessed via /var/www.
Dynamically generating every page, every time it is served, puts an unnecessary load on the CPU. It's better to generate pages in advance and cache them as static HTML files. Cached pages are stored in the web server's root directory so that they can be served without the CMS executing. This significantly decreases page load time and increases the number of concurrent users that a web server can handle.
The site's category structure is also mirrored in the web root directory. When a page is cached, an HTML file is created in the appropriate place in the web root directory. When a page at http://example.com/foo/bar/bletch.html is cached, the complete page will be stored in /var/www/foo/bar/bletch.html.
when you add pages or make changes to your site, you must clear the cache and rebuild it. Cached pages aren't automatically updated when you make changes to your site, so if you to modify a page that's been cached, you need to go to the admin area and click on the "Clear Cache" button. When you've finished making changes to your site, click on the "Build Cache" button to rebuild the page cache.
The example above shows how individual posts are stored, displayed and cached. As well as handling pages that contain individual posts, Pyplate also needs to handle pages that correspond to entire categories. Category pages display all the posts in one category in a single page. These pages correspond to a directory in Pyplate's content directory. To continue using the example above, if a user visits http://example.com/foo/bar/, Pyplate creates a page containing all the posts in /usr/share/pyplate/content/foo/bar/.
When a category page is cached, it is saved in the corresponding place in the web root directory in a file named dir.html. When the page at http://example.com/foo/bar/ is cached, it will be stored in /var/www/foo/bar/dir.html. The web server must be configured to serve dir.html when users request a page that corresponds to a category.
Generating the sidebar every time a page is served would be too time consuming, so the sidebar is cached automatically. The sidebar is cached independently of the rest of the site. Any time a page is requested, Pyplate will check to see if the sidebar has been saved in the template directory. If not, the sidebar will be generated and saved. The next time a page is requested, the sidebar will already exist, so the page load time and the load on the server will both be reduced.
The sidebar file is deleted when the page cache is emptied. It is also deleted when pages or categories are added, modified or deleted.
Share this page: