WordPress, ETag, Last-Modified

WordPress has some pretty crappy code buried in it… the curse of PHP. I can’t complain too much because it’s still a very robust platform with a good community and the best anti-spam plugin. That having been said, WordPress has some broken behavior with respect to feeds and Last-Modified and ETag. The ETag is an MD5 hash of the Last-Modified date, which means there’s not really any empirical value in including both.

Adding in the fact that if the client actually sends an ETagged response (the HTTP 1.1 If-None-Match header), WordPress’s quoting mechanism screws it up. Some people have taken a stab at fixing it but it seems easier to just nuke the @header(“ETag: …) line in wp-include/classes.php (around line 1637 in wordpress 2.0.5) and let last-modified work just fine.

Update: WordPress has another bug that only now becomes evident. If you set a post timestamp in the future, the last-updated timestamp on your feed changes when you save the post, but the post isn’t in the feed. When the post finally appears, the feed comes back 304, even though there’s a new post in it. Ugh. This didn’t show up before because last-modified didn’t work when etag was also sent.

Update 2: I retract everything in update 1. I’m apparently crazy.

This entry was posted in meta, tech. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>