Nasir Aliyev
Nasir Aliyev

How to make sure your page or API always has expected response?

The best ways to ensure that your customers are seeing exactly what you expect them to see, and to maintain the integrity and availability of your services.
How to make sure your page or API always has expected response?

Data is the backbone of the digital world, and for many businesses, web pages and APIs are the primary means of communicating with customers. But ensuring that your pages and APIs consistently deliver the expected response can be a challenging task. In this blog, we'll explore some tips and best practices that can help you achieve this goal and maintain the quality and reliability of your digital services.


Cases when a web page or API can return unexpected results.

There are several common cases when it can happen.

- Hackers have gained access to your website.

- The development process can introduce new bugs, as is typical in software development.

- The website experienced issues during deployment, which caused it to display different information.

- The database has experienced unexpected data changes or deletions.

Let’s take a closer look at the most frequent cases and discuss them in detail.


Hackers have gained access to your website.

According to various reports, thousands of websites are hacked every day.  It's difficult to believe, but every day numerous websites are hacked and their content is altered without the owner's knowledge or permission. You can verify this by visiting one of the mirror websites, such as mirror-h.org (Attack Shadow System), which showcases hacked snapshots of various websites. These attacks can occur at any time, even when your team is not working. To minimize the impact of a hack, it's crucial to react quickly. Small companies often don't have a dedicated security team, and the responsibility falls on the development team's shoulders.

Preventing a hack from happening in the first place is the best course of action, and utilizing security services like ethiack can help. These services continuously check for security issues through automated and manual means, providing peace of mind and reducing the likelihood of a successful attack.

However, even with preventative measures in place, it's still important to monitor your website for any changes. How to do it properly I will tell you in the end.


The development process can introduce new bugs, as is typical in software development.

Making mistakes is a common occurrence during the development process. Consider a scenario where you've built a new feature and added tests, but unfortunately missed out on covering all possible cases with tests. For instance, your development team changed the calculation of votes for products but inadvertently overlooked some edge cases. After deploying the feature, everything seems to be working fine until a customer tries to submit a new vote and encounters an error in the vote calculation. This error causes the votes section of the web page to fail, rendering it inaccessible. Such unexpected issues can impact the user experience and require timely attention to rectify.


The website experienced issues during deployment, which caused it to display different information.

In today's fast-paced business environment, companies strive to maintain resilient systems that can quickly recover from disruptions, automated continuous deployments, and auto-scaling. However, there can still be issues that arise when creating new servers.

For example, consider a scenario where nginx is used as a proxy in each web server. If there is a failure on one of the instances, or if auto-scaling is triggered to create a new instance due to high load, a new instance may be created from an existing docker image. Although the health checks return a 200 OK response, the web page result may just be the default nginx page, which can be surprising and frustrating.

Unfortunately, this is not just a hypothetical scenario. In fact, it was a real example from a project that I personally worked on. Although this particular instance occurred in a development environment, there is no guarantee that it cannot happen in production. And how to be alerted when it happens? I will tell you, in the end. 🙂


The database has experienced unexpected data changes or deletions.

As a developer, imagine that you have write access to the production database. It's the end of a long day, and you're tired, but you still want to truncate one of the tables in the staging database after adding some test data. You open a connection tab and assume that it's for the staging environment. Without double-checking, you run the truncate command, unaware that you're actually connected to the production environment. It's a nightmare scenario, and to make matters worse, you don't check the production environment and assume that the failure you see in the staging environment is due to a problem with the SQL command.

The impact of this mistake can be significant. Let's say that one of the most important blocks in the production database has been truncated, and customers can no longer see the limited deals section on the main page, which is part of an active campaign. This can lead to the loss of thousands or even millions of dollars.


Detecting and mitigating unexpected changes in web pages and APIs.

Now that we've looked at some common scenarios where unexpected changes can occur in web pages or API results, it's important to understand how to detect these changes and mitigate their impact.

Fortunately, there are several SaaS products available that can help with monitoring web pages and APIs for unexpected changes. One such product is Pinghome, which provides different types of monitoring, including "keyword monitoring" for your web pages or APIs.

With Pinghome, your web page source is checked every minute, 24/7, and you will be immediately notified if an expected keyword is missing. You can set up notifications to be sent to your team via various channels such as Slack, Microsoft Teams, custom webhooks, email, or SMS.

By continuously monitoring web pages or APIs for expected keywords, you can quickly detect unexpected changes and take action to minimize their impact. This is one of the best ways to ensure that your customers are seeing exactly what you expect them to see, and to maintain the integrity and availability of your services.