I want to run an update script on pages that haven’t been viewed and updated within X days. I’m using post meta to cache some related RSS feed data, and I want it updated once a week or two, but only if the page has actually been viewed within the last two or three weeks, bots included.
Is there an internal counter or whatnot that has this data, or am I going to have to build something that stores the UNIX timestamp as post meta upon page view?
Post views log/count is not available natively. It is resource-intensive (database writes are much more expensive than reads) and won’t work (if done in pure PHP) with most caching plugins.
There is number of plugins/services that offers Analytics via JS- or image-based tracking. Your best bet is to let such service handle analytics and pull data from there.
Most webservers have a so called logfile. When your site makes use of effective canonical permalinks, you can gain that information from the request URIs stored in the access-log-files.
This can be run as a janitor job in the background once a day/week while querying the URIs against your site’s permalink structure and a genereate superset of all URIs as a hash-table to post IDs.