Oct 012006

In the previous post I showed how I found out it was the ports-deleted page that was causing httpd to die. Since then, I finished my coding to introduce pagination into that URL What was once on one page, is now on 32 pages.

As a added bonus, because the changes were made to the freshports_page_list_ports class, several other pages now benefit from this work. For example, broken, deprecated, ignore, and forbibben are now all paginated. Woo hoo!

I used the Pager module from the PEAR. It took me a while to understand how I could use it. All it does for me is figure out the page numbers to display and tells me what range of ports I need to grab for the page I’m on. That is much easier than me figuring it. Mind you, the page for any given catgory already does this (see the Audio category for an example). I plan to convert other existing paginated URLs to use Pager. It is a much easier solution.

This is not my first venture into PEAR. I also use the HTML_Page2 package for rendering various FreshPorts pages (notably the ones listed two paragraphs above).

Someone also mentioned: why can’t I choose my pagination? Well, why not? I think allowing you to select from 10, 50, 100, and, 500 ports per page should be sufficient for most people. This is a smaller range than the search page but I think it’ll work.

The URLs that use pagination do not, as yet, cache their results. This means that each time you look at the Ports Deleted page it is fresh from the database. That is not the case for each Port page, all of which are cached. The first person to call up a port page after a commit, gets it from the database. The results are stored in the cache for all subsequent readers. The next time a commit occurs for this port, the cache entry is removed.

Extra points

How does one maintain a cache for a page that differs in size for each person? One person might want 50 ports per page, another wants 30. How does you cache that? More to the point, how do you clear that cache when a port commit occurs?

I’ve given it some thought, and I think I have a solution. I’d like to hear what you think first.

Website Pin Facebook Twitter Myspace Friendfeed Technorati del.icio.us Digg Google StumbleUpon Premium Responsive

  One Response to “Paging – a much better way”

  1. This code has been in production for a week or so. It’s been pretty solid. Apache has not core dumped since. I declare it solved.