Nginx: right on time
I want to write about a small trick with SSI, which recently came in handy to me.
Suppose you need to roll out a slightly modified version of a certain page at exactly midnight, or at any other very uncomfortable time when all normal people have been sleeping for a long time. Also, suppose you don’t want to bother with the crown, and in general, everything has been tested a thousand times, so nothing can happen. :)
For this purpose, we can use the nginx SSI. You will not have to make any changes to the nginx config, and the page itself may look something like this:
And now, at exactly midnight, January 1, 2010, your users will see a Happy New Year greetings in the place of some ordinary block. Moreover, at this time you can sleep peacefully (well, or get drunk with friends). :) Moreover, at exactly midnight, the second of January, the congratulation will disappear, without your slightest participation.
This method, of course, can be expanded and improved, achieving the most unusual results. For example, you can, in automatic mode, every Friday, congratulate users on the end of the work week.
Naturally, it also has drawbacks:
- your if will be executed every time the page is served - it can be critical on servers with a very slow processor, or on VPS;
- some time intervals cannot be determined in this way, or it will require more than one “if” operator;
- something else ... :)
But, in general - a good, convenient, and most importantly, quick solution.
Suppose you need to roll out a slightly modified version of a certain page at exactly midnight, or at any other very uncomfortable time when all normal people have been sleeping for a long time. Also, suppose you don’t want to bother with the crown, and in general, everything has been tested a thousand times, so nothing can happen. :)
For this purpose, we can use the nginx SSI. You will not have to make any changes to the nginx config, and the page itself may look something like this:
And now, at exactly midnight, January 1, 2010, your users will see a Happy New Year greetings in the place of some ordinary block. Moreover, at this time you can sleep peacefully (well, or get drunk with friends). :) Moreover, at exactly midnight, the second of January, the congratulation will disappear, without your slightest participation.
This method, of course, can be expanded and improved, achieving the most unusual results. For example, you can, in automatic mode, every Friday, congratulate users on the end of the work week.
Naturally, it also has drawbacks:
- your if will be executed every time the page is served - it can be critical on servers with a very slow processor, or on VPS;
- some time intervals cannot be determined in this way, or it will require more than one “if” operator;
- something else ... :)
But, in general - a good, convenient, and most importantly, quick solution.