How to cache tidy pics

Tidy pics are using .php extension. So in this case how can we cache header. We added in cache headers and expire headers all extensions of images but major portion of images are in tidy pics and those are using .php extension. So this case is there any alternative way to cache those pics too?