Designing a Web API – Introduction

These days, having back-end as a service and then using one sort of JavaScript frameworks have become a trend in developing web applications.

Apart from that, many service providers have had their SOAP web services to communicate with their customers and some are re-designing their API in REST-ful manner. Following a correct approach in designing the API is an important aspect of application architecture because consumers should be able to use the exposed api in a somehow standard way.

ASP.NET MVC Output Caching

We can follow every kind of performance tuning tips & tricks on server side code and on the database queries and indexes. But our application can perform better if it doesn\’t need to go through all those logic and have the response ready for the users.

This is partly can be done by utilizing caching mechanism.

OutputCache Attribute

the OutputCache attribute exists on System.Web.Mvc namespace and provides a simple and quick way for the developers to set their caching setting on any controller (or entire class if required).

public class HomeController: Controller 
    [OutputCache(Duration = 300, VaryByParam = "none)]
    public ActionResult Index() 
        return View();

Modularizing JavaScript Code

Global Namespace Pollution

All JavaScript codes can run inside Global Execution Context. This means that if we define variables and functions at the global level, then the other codes can access them, no matter where they are and even if they are in different files.

<!DOCTYPE html>
<html lang="en">
        <script type="text/javascript" src="file1.js"></script>
        <script type="text/javascript" src="file2.js"></script>
        <!-- body -->


© 2019. All rights reserved.