Make Discourse play nice with the Wayback Machine

(Dan Dascalescu) #1

I’ve noticed that when archiving Discourse topics using, the CSS is mangled. Here is an example:

List of project ideas for Google Summer of Code 2016
Discourse is feeding js to again
(Jeff Atwood) #2

Cannot be resolved, as wayback does not understand and cannot archive pure JavaScript sites at all. Either you serve it plain crawler HTML, or it will show nothing.

You may want to raise this with them, if they can make their crawler archive pure JavaScript sites, but it requires an extremely advanced crawler that runs headless browsers. Pure text curl retrieval is no longer sufficient, they have to retrieve the JS and execute it.

(Kane York) #3

orrrrr we could build a topic view that looks like this :smile: (from my experiment branch)

This layout is both extremely easy to crawl, and works with both wide and narrow screens.

However, I seem to have forgotten the topic’s category.

How about Discourse Support Google AMP?
(Jeff Atwood) #4

Very strongly opposed to adding another renderer, one that has to be kept in sync with the primary JavaScript renderer, plus the crawler 1996 HTML renderer we already have.

(Kane York) #5

The way I have it implemented, this replaces the crawling view outright on topics.

(Felipe Corrêa Da Silva Sanches) #11

May I suggest we focus back on the original issue here?

There’s people willing to use the Internet Archive Wayback Machine (myself included) in order to keep copies of Discourse threads for posterity and right now that seems to be impossible to achieve with the current implementation (of both Discourse and Wayback).

What are the things that can be done to the Discourse codebase that can improve this? And what are the things that can be done on the Archive’s crawling system that could help as well?

(Jeff Atwood) #12

I believe the CSS should look a lot better with @falco’s latest changes in that area. Can you quickly check using the tools @falco?

(Rafael dos Santos Silva) #13

I think all we need is detecting UA as a crawler, let me take a look.

(Felipe Corrêa Da Silva Sanches) #14

I actually experienced a server error while attempting to save a Discourse page on the wayback machine today:

This was the original URL:

And I was trying to save it this way:

(Rafael dos Santos Silva) #15

OK, this is kinda strange.

They are using the User Agent of the user who asked to save the page to download the HTML, and after that they try to show the page with a bunch of injected JS.

This topic when I click on the save button using Google Bot User Agent: Make Discourse play nice with the Wayback Machine - feature - Discourse Meta

Sent an email to, let’s see.

(Sawood Alam) #16

That’s not enough actually, because there are many other web archives in town and new web archives come to life every now and then.

(Sawood Alam) #17

There are many efforts of headless browser based archiving including which is an on-demand single page archiving system. It renders the page using PhantomJS and then archives the rendered DOM plus necessary assets. However, doing it on a massive scale (not just for on-demand pages) takes a lot of time, because PhantomJS or any other renderer is orders of magnitude slower than traditional vanilla crawlers such as Heritrix that is used my Internet Archive and many other web archives.

Here is a relevant research work on the topic Scripts in a Frame: A Two-Tiered Approach for Archiving Deferred Representations. Below is a blog post summarizing the research work and related resources.

(Rafael dos Santos Silva) #18

Actually that didn’t work because they aren’t respecting user agent.

Discourse is already crawler friendly, you just need to ask the crawler version.

(Graham Perrin) #19

Attempts by me to save this topic result in:

I can not describe the procedure, or the end result, as playing nicely.

(Jeff Atwood) #20

We should follow up and see if we can improve this somehow @falco, perhaps in the next few weeks or early after 1.9 begins beta.

(Rafael dos Santos Silva) #21

The problem, as described above, is that Wayback machine is not being nice, because they hijack their user-agent string, making it impossible for use to serve a non-js crawler version for then.

I tried their e-mail but got 0 responses.

(Sawood Alam) #22

@Falco, the Wayback machine is the archival replay system. The crawler used at Internet Archive is Heritrix. That said, would you mind telling me the exact user-agent string you are seeing from them? I might be able to approach some people at Internet Archive on personal channels and see what’s going on.

(Rafael dos Santos Silva) #23

Wow, this is amazing! :tada:

It’s like I said here:

For example, if you are using Firefox 52 and click on the save, they will use your user-agent (Firefox 52 user agent) when asking the page.

If they add something that can distinguish this requests, we can serve the correct page.

(Sawood Alam) #24

I will try to talk to some friends at the Internet Archive later this week. Next month I will be meeting with many web archive folks (including Internet Archive) at an International Internet Preservation Consortium conference. I will raise this issue there.

(Graham Perrin) #25

Thanks, and to clarify: I did not suggest that Discourse did not play nicely. Please see earlier versions of my post, keyword:

  • /print

– I meant to say that the print workaround is not nice. I do not recommend it.