-1

I have been spending quite a lot of time trying to decide if I should use apache** or nginx. I am very biased towards nginx due to the simple configuration, better scalability and it just feels more secure overall.

However, AJAX is a must have on my list of requirements, so if nginx prohibits the implementation of AJAX, or if it is just not worth the effort, then I wouldn't mind using apache.

So the question is, does the choice of the web server (in my case nginx vs. Apache) makes a difference when one wants to implement AJAX? Are there any additional components/installations required?

**For the purpose of answering this, I suggest to treat httpd and tomcat as one and the same.

6
  • 5
    What do you even mean by your question? What do you think AJAX is? Commented Jan 5, 2017 at 16:51
  • Is it possible to implement AJAX on nginx? Commented Jan 5, 2017 at 16:53
  • 4
    AJAX is client-side, so servers don't need to implement anything special to support AJAX. So the answer to your question is yes.
    – Jasmijn
    Commented Jan 5, 2017 at 16:55
  • @Robin Thanks for clearing my misunderstanding. I was planning on learning AJAX after choosing a server so I had no clue. Commented Jan 5, 2017 at 17:03
  • 3
    Note this question was used as an example in this meta post.
    – Doc Brown
    Commented Jan 11, 2017 at 8:29

1 Answer 1

12

Your question shows that you misunderstood AJAX, Apache and Nginx.

AJAX is simply a technique for a browser to request some information from a server without refreshing the web page. It consists of an HTTP (or HTTPS) request sent by the browser to the server. For a web server such as Apache or Nginx, it makes technically little difference if the HTTP request is made through AJAX or not: it's still an HTTP request, and nothing more.¹

On server side, requests are somehow processed. They could lead to a static resource, such as a CSS file or a JPEG image or an HTML document stored somewhere on the server, or they can be dynamic, which means that they lead to the execution of the custom source code—it could be code written in Python, Ruby, Java, PHP, whatever. While nothing prevents you from having a static website which makes AJAX requests to static resources, frequently AJAX is associated with dynamic websites.

This leads us to the choice of the web server. Actually, what you were probably searching is if a given server can run your app written in a given language. For instance, LAMP bundle is well-known for allowing to run PHP websites using Apache; there is a strong support for it, and setting up the environment is relatively easy. Unsurprisingly, Nginx supports PHP too. However, more esoteric languages may have a better support on one server compared to another, and that would be important to know before determining which server you should actually use. note that FastCGI—the glue between web servers and programs—make it possible to develop web apps with virtually any programming language and host them on virtually any popular web server.

But there is a better alternative: try both Apache and Nginx, and see yourself which one fits better your needs!


¹ A slight specificity of AJAX requests is that they tend to be small but frequent. It is not inherent to AJAX itself—nothing prevents you from writing a web app which makes requests rarely, and receives a lot of data, but it is common to have AJAX-enabled apps to do a lot of tiny requests. This specificity could influence your choice of server infrastructure, would it be the actual web server or the reverse proxy, the version of HTTP, etc. However, don't focus on those aspects for now. Once you have a basic understanding of web servers, web apps and HTTP, only then those subjects would actually matter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.