Thanks for writing that (my emailed version seems to display what you actually wrote). It looks exactly like what I'd thought of as the "correct"/straightforward mimetex plugin script. You might want to add an align=\"middle\" to your <img> tag. That's typically the more aesthetic-looking image alignment relative to surrounding text.
To verify that images are cached in -DCACHEPATH=\"path-to-images/\" just dir (windows) or ls (unix or linux) path-to-images/ from the command line, and see what's there. One thing that should be there is the ascii file mimetex.log, which you can read with any file editor to see the names and contents of all the gif files cached in your path-to-images/ directory.
Please note that you have to mkdir path-to-images/ (relative to the cgi-bin/ directory where mimetex.cgi resides) yourself, before running mimetex. If the directory specified by -DCACHEPATH=\"path-to-images/\" doesn't already exist when mimetex runs, then it just generates requested images without caching them. So be sure to mkdir path-to-images/ corresponding to -DCACHEPATH=\"path-to-images/\"
To "recall" cached images, just run mimetex in the usual way. When it's compiled with -DCACHEPATH=\"path-to-images/\" then it automatically checks path-to-images/ for an already-cached image of your requested expression. You don't have to do anything different than usual. If mimetex finds a cached image, it just uses that image without re-rendering it. Otherwise, it renders new images and caches them for future use.
You might think mimetex is an awfully big program to run just to retrieve cached images. But think how paged memory management typically works on all modern os's. Only the very few pages of memory required for mimetex's caching code will actually be loaded, not the whole program (and none of the font data).