Generating an Etag based on body in mod_perl

312 Views Asked by At

I have some old mod_perl code that generates dynamic content. I was asked to implement sending an Etag on each reply.

It seems the way to do this might be to add a mod_perl handler, but this content is generated dynamically, so I need to make the Etag a checksum of the response body. I have yet not found a way to get the contents of the response body in a mod_perl handler to checksum it.

How should I dynamically generate Etags based on the response body in mod_perl?

1

There are 1 best solutions below

0
Lajos Veres On

If your content is dynamically generated then probably the easiest way to set the etags to totally random numbers. (And this is also the safest way...)

Or maybe you can create a heuristic like creating a hash from the url/get/post parameters. If you can't create this kind of heuristic it means that your internal logic is based on other internal states. (session/etc) So probably the total random etags are the best solution.