An approach that seems to be working for me is to switch to LuaTeX, specifically the LuaLaTeX package, both from the current MiKTeX distribution for Windows.
This has allowed me to write a Lua module that I load with \directlua{require"dictfun"} in my document's preamble. When the dictfun module loads, it tries to initialize a table of the headers for every page from a file named after the \jobname, found in the global tex.jobname. I used \makeevenhead and \makeoddhead to hook into the page header and call a Lua function from dictfun to update the index of header info and construct the text that belongs on this page's header. The text of the header is placed from the Lua side with a call to tex.print().
Finally, after the main body is finished, I make one more call into the Lua module to write out the current content of the index table.
This solution requires that the text be processed by lualatex at least twice with the pagination stable, but that isn't an unreasonable requirement.
I'm sure it could be done in pure TeX, but building data structures is something that native Lua does very well.