Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the best method for taking a site down and kicking out users to do an upgrade?

I'm wonder how people are kicking people out or blocking access to a site when you want to do an upgrade and you have users that are logged in.

My one thought is to just put a bool setting in a global file (such as the settings file) for whether or not the site is unavailable. True is available, while false is unavailable. When false, the next time the user attempts to access the site they will either be logged out or just presented with an unavailable message.

There are 2 issues I can see with this method:

  1. If users are just finishing filling in a long form or writing a large portion of text (like a new question or answer on SO), as soon as they submit the form, they'd lose that information. (Can't always save it, because there maybe DB changes for that table or code may have changed already.)

  2. Possible: On a busy site, editing the global file if it's more than a couple lines it might cause PHP parse errors if that page is loaded while it's partially uploaded or while saving. There might also be locking issues on the file, depending on the configuration.

Another option is to have a field in the database with the same setting. At the moment, I don't generally have a table for settings, so this would be the only thing in the table, but I could see it being faster as it avoids the second problem.

Is there something that you've used that worked well or any other ideas?

I'm working with LAMP.

like image 679
Darryl Hein Avatar asked Mar 19 '09 23:03

Darryl Hein


People also ask

What is website upgradation?

Website Revamp/ Upgrading website means bringing it to the cutting-edge of technology for optimal results and increased revenue & profits. A successful website revamp or website redesign services help you deliver a better user experience across different devices and browsers. An upgraded website is: Fast loading.

What happens when you take down a website?

However, just closing down the website won't stop people from attempting to go to your website. People will still land there and get an error page. It takes several weeks for your URLs to fall out of the search engine results, and possibly longer if you have a lot of backlinks.


1 Answers

You might want to utilize a webserver redirect. In case of Apache, a .htaccess file to redirect (or rewrite url) users to a static maintenance page:

RewriteRule ^updating.*$ $0 [NC,U,QSA,L]
RewriteRule .* /updating/ [NC,U,QSA,R=307,L]

In case you want to access the site yourself when in the maintenance mode, you can attach a specific and hopefully-unique string to the useragent header:

RewriteRule ^updating.*$ $0 [NC,U,QSA,L]
RewriteCond %{HTTP:User-Agent} !MY-CUSTOM-UA-STRING [NC]
RewriteRule .* /updating/ [NC,U,QSA,R=307,L]

Here's how to manipulate your user-agent in firefox:

Create a new about:config key named general.useragent.extra.XYZ and set it as "MY-CUSTOM-UA-STRING" or anything else you wish. Firefox will attach the string to the UA.

If using Chrome, try the new Mobile Emulation feature which allows you to modify the user-agent string directly from the devtools.

As you've mentioned yourself, an alternative solution could be setting of a config flag on the server side. Before making so, I suggest that you save all the user's ongoing operations on the site and let her resume them after the maintenance period. Also, let them know the exact time of maintenance beforehand.

like image 172
sepehr Avatar answered Oct 21 '22 02:10

sepehr