What about building a lightweight database, e.g. SQLite? You can directly query the expired pages, and sometimes (not at every run) check the other pages, decreasing the cost.