I have a Drupal 6 website and I want to write a module that will cache nodes based on the published date. Older nodes would be cached longer than newer nodes. I plan to use cache_set(), cache_get() and nodeapi hooks to add the node to the cache and check if it is in the cache before loading. However I am not sure if my logic is correct. Can provide any tips to put me on the right track?

  • I think by default your content will be cached. Dec 29, 2012 at 10:39
  • I know the content will be cached by default by Drupal but I want to cache each node variably based on the published date. I am guessing that I should simply use a cache expire time on each node using a hook. Just not sure which hook to use.
    – Binny
    Dec 29, 2012 at 12:53
  • what exactly are you trying to cache here? the page cache contains all of the markup of an entire page, eg, the the css and js declarations, and the entire html of the page which includes all the usual page headers and blocks and so forth. Nodes, on the other hand, include just the content of that specific node, and, if you are going to be using nodeapi() hooks, all the heavy lifting database wise has already been done, unless the rendering of that information into html is huge. But then at that point, you certainly could do caching much like how block caching is done.
    – Jimajamma
    Jan 3, 2013 at 13:53

1 Answer 1


Boost could do this. Core can not due to the cache_page bin/table getting cleared on cron & node save. Boost has a cache expiration block that allows for different cache lifetimes.

  • Boost seems to be a good candidate. Thanks for the help. Still Boost does not have a central configuration page where we could set the expiration time of nodes based on factors like node published date.
    – Binny
    Dec 31, 2012 at 3:36
  • This is correct. That is why I used "could" and not "can" in the first sentence :) With boost it is technically possible and it shouldn't be "hard" to program; problem is the code to make your request happen hasn't been written.
    – mikeytown2
    Dec 31, 2012 at 6:15
  • I get the point. I guess its time I created a Boost 'plugin'
    – Binny
    Jan 1, 2013 at 7:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.