I'm posting this here in case someone else encounters this issue.

There seems to be a problem with anonymous page cache and LiteSpeed servers (perhaps others too). When serving an anonymous cached page, Backdrop (or the server?) sends the http header twice, and all the content twice in the same document. 

Additionally, this error is generated:

Warning: session_set_save_handler(): Cannot change save handler when headers already sent in backdrop_session_initialize() (line 245 of /home/XXX/public_html/backdrop/core/includes/session.inc).

In order to see the duplicated items on the browser, I had disabled the Backdrop setting for compressing cached pages.You can see the duplication here.

This issue goes away if I turn off page caching for anonymous users here: admin/config/development/performance

I'm not sure why this is happening, whether it's an issue with the server or with Backdrop. This is related to another post of mine in this forum. In that case, I had the "Compress cached pages" on, which resulted on Safari throwing an error when it received the duplicated items (the duplicated "page" was sent compressed, which broke the browser processing of the page) .


So, here's one more piece of information: the issue seems to be resolved if I enable " Cache pages for anonymous users" AND I disable  "Use background fetch for cached pages".

It looks like the problem is background fetching. I'm not sure how background fetching works, but it seems to be sending headers and content twice in the same response. Perhaps someone with more experience with caches and background fetching can explain this.

I have Apache in my local, and this issue is not happening there, only with the production (LiteSpeed) server.

And some more information: it seems like the duplication of headers and content only happens if the site is set to display "All messages" in "Error messages to display" in admin/config/development/logging. If you set that to "None" the errors/duplication will not happen, even if background fetching is on.

I was thinking it might have something to do with background fetching. You might be the first to use it with Litespeed. Sounds like it needs a new issue.