Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2021-12-23 18:09:14

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

Article status for maintenance mode, returns HTTP status

I am sure this has been asked before, but my search fu is not strong this evening. I had a client ask me about this today and I’ve told her I’ll check what’s viable.

Consider a site where one or more articles need maintenance, to the extent that an alternative page should be shown in place of regular content.

Example: a website has an article that has incorrect advice on a subject, and the article needs to be pulled offline immediately (for moral / legal / ethical reasons), and a holding page (with appropriate HTTP status) is used to indicate that the article is down for maintenance, but will return. An audit can take place, the preview functionality still works behind the scenes, and the article can be republished post-audit. The holding page is removed, all is well.

I know a lot of stuff in articles is sacred, especially with backward compatibility concerns, but a user-friendly way to make one or more articles ‘currently unavailable’ – for want of a better term – would be valuable.

(Explaining it like this is useful to me because it dawned on me that this might already be doable with an alternate article form…but could an article form trigger an HTTP header?)

Usual caveat: could be plugin territory, of course.

Last edited by gaekwad (2021-12-24 16:45:41)

Offline

#2 2021-12-23 18:58:45

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: Article status for maintenance mode, returns HTTP status

Long shot: set the expiry date/time. Then in your template use the <txp:if_status> to check for 410: Gone and render something else temporarily. Then remove the expiry time to reinstate it.

Alternatively, make an error_410 template and render that instead. You could perhaps use a custom field to hold the message you want to display.

Does that give you any avenue for thought?


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#3 2021-12-23 20:31:25

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

Re: Article status for maintenance mode, returns HTTP status

Bloke wrote #332296:

Does that give you any avenue for thought?

Thanks, Stef. I was thinking to 503 it so it’s seen to be ‘back soon’, so perhaps the article form route will be the way forward, and there’s less mess with expiry date + human error. Choose the article form from a dropdown instead of changing publication dates, and so on.

Are there any limitations on where header can be called from? Specifically, if an article fires a header with status 503 (or whatever), does that then kick off a second pass?

Offline

#4 2021-12-23 21:12:17

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: Article status for maintenance mode, returns HTTP status

Hmmm. The thing is, 503 is usually a site wide header. I’ve never seen it used on a per article basis so I’m not entirely sure what search engines will make of its use.

Form override would work though. Hadn’t thought of that.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#5 2021-12-23 21:39:11

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

Re: Article status for maintenance mode, returns HTTP status

Bloke wrote #332299:

The thing is, 503 is usually a site wide header. I’ve never seen it used on a per article basis so I’m not entirely sure what search engines will make of its use.

Yes, you’re right – I had considered this. I’m pondering pros and cons. I was using this as a guide, but as you rightly say – that’s a whole website.

I am brave enough to suck it and see, at least on a test site. I can grep the logs to see if there’s a trigger for the rate of 503s before a search engine bounces away.

Offline

#6 2021-12-24 09:24:13

phiw13
Plugin Author
From: Japan
Registered: 2004-02-27
Posts: 3,058
Website

Re: Article status for maintenance mode, returns HTTP status

I have done the way suggested by Stef: error_410 with the addition of a <txp:if_article_id …/> containing a special message, because the form was already used for things that were really gone.

Bit of sledgehammer approach and some manual work in multiple panels but that was otherwise a relatively “easy” way.

Ideally I would have used a temporary redirect header (307) but could not get it to work. That kind of stuff seems difficult on per article basis in TXP.


Where is that emoji for a solar powered submarine when you need it ?
Sand space – admin theme for Textpattern

Offline

#7 2021-12-24 12:12:40

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

Re: Article status for maintenance mode, returns HTTP status

phiw13 wrote #332303:

I have done the way suggested by Stef: error_410 with the addition of a <txp:if_article_id …/> containing a special message, because the form was already used for things that were really gone.

This is interesting. The 410 approach – to me at least – implies content is gone and isn’t coming back…which is not what I want. MDN says:

The HyperText Transfer Protocol (HTTP) 410 Gone client error response code indicates that access to the target resource is no longer available at the origin server and that this condition is likely to be permanent.

…but throwing a 404 feels wrong. Sure, it can be styled, but it could feel a bit fatal from the client point of view.

Ideally I would have used a temporary redirect header (307) but could not get it to work. That kind of stuff seems difficult on per article basis in TXP.

Also interesting – I had considered 3** responses, but a 307 implies a redirect target is involved, and if there’s >1 articles going to a generic “be right back” page, that could be a mess to untangle. I suppose if it’s temporary then any sensible crawler would know this and stop back later, especially if I set a header to check back at a given time.

Lots to think about. I will ponder this over the holidays.

Thank you, both – I very much appreciate your input.

Offline

#8 2021-12-24 14:04:00

Bloke
Developer
From: Leeds, UK
Registered: 2006-01-29
Posts: 11,250
Website GitHub

Re: Article status for maintenance mode, returns HTTP status

Yeah, 410 is a bit sledgehammerish.

Is there no http status code for “be right back”? Cos if there is, Txp can throw it via Form override or (probably) in the page template if the page layout is refactored slightly so the header tag can be sent early.


The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.

Txp Builders – finely-crafted code, design and Txp

Offline

#9 2021-12-24 14:17:38

etc
Developer
Registered: 2010-11-11
Posts: 5,028
Website GitHub

Re: Article status for maintenance mode, returns HTTP status

Could 302 Found be of order here?

Offline

#10 2021-12-24 15:39:21

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

Re: Article status for maintenance mode, returns HTTP status

etc wrote #332306:

Could 302 Found be of order here?

Yes, I think there’s potential there. Thanks, Oleg.

I asked on StackOverflow earlier – here – and the most sensible reply so far – here – says 302, too.

Offline

#11 2021-12-24 15:42:07

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

Re: Article status for maintenance mode, returns HTTP status

Bloke wrote #332305:

Is there no http status code for “be right back”? Cos if there is, Txp can throw it via Form override or (probably) in the page template if the page layout is refactored slightly so the header tag can be sent early.

Another (expensive) way around it would be to have an article tag in head that spits out a status code, and any other conditional stuff it’s not a normal, live article.

Offline

#12 2021-12-24 16:46:23

gaekwad
Server grease monkey
From: People's Republic of Cornwall
Registered: 2005-11-19
Posts: 4,134
GitHub

Re: Article status for maintenance mode, returns HTTP status

gaekwad wrote #332308:

I asked on StackOverflow earlier – here – and the most sensible reply so far – here – says 302, too.

…and then my question was marked as a dupe and I was pointed to here, and I’m back to 503 again.

Offline

Board footer

Powered by FluxBB