SlideShare una empresa de Scribd logo
1 de 21
Tips and Tricks For Faster ASP.NET and
MVC Web Applications
By Sarvesh Kushwaha
1. Static Resources should be Cacheable ;)
Above code cache all static resources for 365 days.
2. Bundling and Minification
Reduce the amount of data (CSS & JavaScript) sent across the
network using Bundling and Minification in ASP.NET 4.5 .
Bundling is merging all CSS files into one and same for JavaScripts file
.This Reduce the number of requests to server.
Minification is removing blank space b/w words and lines and
more then that ;) .
LINK : HOW TO DO IT
3.Use View State when its necessary
Every control has ViewState in Asp.Net and ViewState is turned on in
ASP.NET by default.
ViewState is an unnecessary overhead for pages that do not need it. As
the ViewState grows larger, it affects the performance of garbage
collection. ViewState gets store in hidden field too many field can make
a web page heavier and will cause rendering problem.
So Disable ViewState for every control, untill you need it (have to keep
data on post backs of a page).
1. You know you don't need ViewState for a textbox control and similar control untill
you are performing textchange_event. So disable it by using EnableViewState=
“false” for each one.
2. Disable ViewState at page level add in page : <%@ Page EnableViewState="false"
%> .
3. Disable ViewState at Application level add in web.config : <pages
enableViewState="false" />.
4. Use Effecting Paging
• Bring small set of data at once ,show them using paging to render the page quickly.
• Large set of data use stored procedure for page index data and filtering .
LINK: HOW TO DO IT
5. URL Compression
Now with IIS 7 we can do HTTP compression of data being send over the
network . Add following Xml snippets in the web.config file under
<system.webserver> node :
<urlCompression doDynamicCompression="true" doStaticCompression="true"
dynamicCompressionBeforeCache="true"/>
• doDynamicCompression tells IIS whether it should compress dynamically
generated content, i.e. content generated by your scripts (ASP, ASP.NET, PHP
…).
• doStaticCompression tells IIS whether to compress static files (PDF, JPEG …)
,those actually exist on the file system.
• dynamicCompressionBeforeCache attribute specifies whether IIS will
dynamically compress content that has not been cached.
6. Use Sprite Images
use sprite images instead of using several images so at one download you can
use several small images .
Now we can make sprite images very easily using Some NUGET packages.
Below are some :
7. Image Optimization
• Normally images take largest percentage (size) in a web page. image
optimization help us to increase performance . Using Asp.net Nuget we can
optimize images :
• Allocate space for image using <height/> and <width/> , it will let page
rendering more quickly .
8. Always Deploy in Release Mode
• At the time of deploying our main concern is performance , Debug Mode
creates .pdb file and take some info generated by JIT to code address mapping
.
• Code is more optimized in Release Mode.
• Less memory is used by the source code at run time in Release Mode.
• Set debug=“false” in web.config for release mode.
9. Use client Side Validation
At max one should use client side validation for application as it gives user a friendly experience
and reduce the over head of post back to the server.Where secuirty is priority use server side
validation .
10. Remove Unnecessary HTTP Headers
The X-AspNet-Version, X-AspNetMvc-Version, X-Powered-By, and Server HTTP headers
provide no direct benefit and unnecessarily used a small amount of bandwidth.
• Removing X-AspNet-Version : Under <System.web> add this <httpRuntime
enableVersionHeader="false"/>
• Removing X-AspNetMvc-Version : Add this in Global.asax.cx file
MvcHandler.DisableMvcResponseHeader = true;
• Remove Server HTTP Header : LINK HOW TO DO IT
• Remove or Edit X-Powered-By : IIS7 Manager > HTTP Response Header > Edit or Remove
11. Pipeline Optimization
• There are many default HttpModule which sit in request pipeline and intercept each and every request.
• Example If you are not using window authentication you don’t need window authentication HttpModule.
Add following code in web.config :
<httpModules>
<!-- Remove unnecessary Http Modules for faster pipeline -->
<remove name="Session" />
<remove name="WindowsAuthentication" />
<remove name="PassportAuthentication" />
<remove name="AnonymousIdentification" />
<remove name="UrlAuthorization" />
<remove name="FileAuthorization" />
</httpModules>
12. Use Content Delivery Network
• Better if you download things from nearest server from your palace .its like
travelling things from one country to another which takes times. If application
has large number of images, CSS, JavaScript sending request for each of them
and downloading them across the world will take significant time.
• Content Delivery Network deal with static cacheable Content .
• Bootsrap Used CDN for his latest release ;)
13. Dispose Objects Manually
• Although Objects will be cleaned up when they are no longer being
used and when the garbage collector sees fit. Always dispose an
object which implements IDisposable ,to do so Use a USING
statement to automatically dispose of an object once your program
leaves the scope of the using statement.
using (SqlConnection cn = new SqlConnection(connectionString))
{
using (SqlCommand cm = new SqlCommand(commandString, cn))
{
cm.ExecuteNonQuery();
}
}
14. Effective use of Jquery AJAX in Asp.ne
• Use ajax to download data asynchronously, which are not needed
immediately like content of Accordion (Collapsed Panel) and tabs.
• Don’t make too much ajax requests
• Use ajax when its needed to load more data when user scrolls,
when user is not scrolling there is no benefit to bring all the data at
once.
15. Do use magic of Asynchronous
Methods
If your page needs to access multiple data sources , then use
asynchronous methods to parallelize access to those sources .
LINK : HOW TO DO IT
16. Turn off Tracing unless until its required because its keep track
of the application's trace and the sequences. Under <system.web>
node write following code:
<trace enabled="false" pageOutput="false" />
<trace enabled="false" requestLimit="10" pageOutput="false"
traceMode="SortByTime" localOnly="true"/>
17. Instead of Respons.Redirect() use Server.Transfer() when we
want to transfer current page request to another .aspx page on the
same server. it helps to reduce server requests. And optionally give
us value of preserve query string and form controls values .
18. String Management :
• Use += operator or String.Concat() when the number of appends is know and short .
• Use StringBuilder object when number of appends is unknown.
19. Asp .NET literal and label are different
• Literal just show that text they don’t add the extra markup.
• Label add the extra markup <label><label/>.
20. Remove Blank Space and lines from HTML
• Using Regular Expressions in VS2012 remove blank lines from .aspx and HTML
^(?([^rn])s)*r?$r?n
• Use CodeMaid tool to remove spaces and more.
21. Use Performance Tools
Correct code makes good performance
• Backend performance Tools : DotNetMemoryProfiler,
SQLServerProfiler
• Performance Tools :
• Static analysis tool : Yslow
• Run Time Profiler : Speed tracer for chrome, Firebug for firefox, IE
Developer tools
• Others : WebPageTest , Page-analyzer , Pingdom
• Monitoring Tool : Fiddler
Developer Checklist
Caching
Client Side Validation
Use ViewState if needed
Dispose Objects ManuallyCDN
Remove Unneccesary HTTP Headers
Effective Paging URL Compression
Pipeline Optimization
Release Mode
Images Optimization & Sprite Images
Bundling and Minification
Jquery Ajax Async and Await Turn Tracing Off
Sarvesh Kushwaha | | | | | |

Más contenido relacionado

La actualidad más candente

Software Requirements
 Software Requirements Software Requirements
Software RequirementsZaman Khan
 
Decision Table Based Testing
Decision Table Based TestingDecision Table Based Testing
Decision Table Based TestingHimani Solanki
 
Difference between Stubs & Drivers
Difference between Stubs & DriversDifference between Stubs & Drivers
Difference between Stubs & DriversProfessional QA
 
What is Test Plan? Edureka
What is Test Plan? EdurekaWhat is Test Plan? Edureka
What is Test Plan? EdurekaEdureka!
 
scenario testing in software testing
 scenario testing in software testing scenario testing in software testing
scenario testing in software testingdurgaaarthi
 
Test design techniques: Structured and Experienced-based techniques
Test design techniques: Structured and Experienced-based techniquesTest design techniques: Structured and Experienced-based techniques
Test design techniques: Structured and Experienced-based techniquesKhuong Nguyen
 
INTRODUCTION TO ISTQB FOUNDATION LEVEL - CTFL
INTRODUCTION TO ISTQB FOUNDATION LEVEL - CTFLINTRODUCTION TO ISTQB FOUNDATION LEVEL - CTFL
INTRODUCTION TO ISTQB FOUNDATION LEVEL - CTFLRahul R Pandya
 
Software engineering quality assurance and testing
Software engineering quality assurance and testingSoftware engineering quality assurance and testing
Software engineering quality assurance and testingBipul Roy Bpl
 
Automation Testing with Test Complete
Automation Testing with Test CompleteAutomation Testing with Test Complete
Automation Testing with Test CompleteVartika Saxena
 
Pipes & Filters Architectural Pattern
Pipes & Filters Architectural PatternPipes & Filters Architectural Pattern
Pipes & Filters Architectural PatternFredrik Kivi
 

La actualidad más candente (20)

What is Exception Handling?
What is Exception Handling?What is Exception Handling?
What is Exception Handling?
 
Software Requirements
 Software Requirements Software Requirements
Software Requirements
 
Decision Table Based Testing
Decision Table Based TestingDecision Table Based Testing
Decision Table Based Testing
 
Object model
Object modelObject model
Object model
 
Difference between Stubs & Drivers
Difference between Stubs & DriversDifference between Stubs & Drivers
Difference between Stubs & Drivers
 
Software quality assurance
Software quality assuranceSoftware quality assurance
Software quality assurance
 
White box ppt
White box pptWhite box ppt
White box ppt
 
What is Test Plan? Edureka
What is Test Plan? EdurekaWhat is Test Plan? Edureka
What is Test Plan? Edureka
 
scenario testing in software testing
 scenario testing in software testing scenario testing in software testing
scenario testing in software testing
 
Test design techniques: Structured and Experienced-based techniques
Test design techniques: Structured and Experienced-based techniquesTest design techniques: Structured and Experienced-based techniques
Test design techniques: Structured and Experienced-based techniques
 
Software testing
Software testingSoftware testing
Software testing
 
Functional and non functional
Functional and non functionalFunctional and non functional
Functional and non functional
 
Debugging
DebuggingDebugging
Debugging
 
INTRODUCTION TO ISTQB FOUNDATION LEVEL - CTFL
INTRODUCTION TO ISTQB FOUNDATION LEVEL - CTFLINTRODUCTION TO ISTQB FOUNDATION LEVEL - CTFL
INTRODUCTION TO ISTQB FOUNDATION LEVEL - CTFL
 
Software engineering quality assurance and testing
Software engineering quality assurance and testingSoftware engineering quality assurance and testing
Software engineering quality assurance and testing
 
Automation Testing with Test Complete
Automation Testing with Test CompleteAutomation Testing with Test Complete
Automation Testing with Test Complete
 
Pipes & Filters Architectural Pattern
Pipes & Filters Architectural PatternPipes & Filters Architectural Pattern
Pipes & Filters Architectural Pattern
 
unit testing and debugging
unit testing and debuggingunit testing and debugging
unit testing and debugging
 
Manual testing
Manual testingManual testing
Manual testing
 
Software Verification & Validation
Software Verification & ValidationSoftware Verification & Validation
Software Verification & Validation
 

Destacado

Scaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersScaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersoazabir
 
10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websites10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websitesoazabir
 
ASP.NET MVC Performance
ASP.NET MVC PerformanceASP.NET MVC Performance
ASP.NET MVC Performancerudib
 
Four Ways to Improve ASP .NET Performance and Scalability
 Four Ways to Improve ASP .NET Performance and Scalability Four Ways to Improve ASP .NET Performance and Scalability
Four Ways to Improve ASP .NET Performance and ScalabilityAlachisoft
 
Building Scalable .NET Web Applications
Building Scalable .NET Web ApplicationsBuilding Scalable .NET Web Applications
Building Scalable .NET Web ApplicationsBuu Nguyen
 
Web api scalability and performance
Web api scalability and performanceWeb api scalability and performance
Web api scalability and performanceHimanshu Desai
 
Updated Mvc Web security updated presentation
Updated Mvc Web security updated presentationUpdated Mvc Web security updated presentation
Updated Mvc Web security updated presentationJohn Staveley
 
Architecting ASP.NET MVC Applications
Architecting ASP.NET MVC ApplicationsArchitecting ASP.NET MVC Applications
Architecting ASP.NET MVC ApplicationsGunnar Peipman
 
JavaScript For CSharp Developer
JavaScript For CSharp DeveloperJavaScript For CSharp Developer
JavaScript For CSharp DeveloperSarvesh Kushwaha
 
Scaling your servers with async and await
Scaling your servers with async and awaitScaling your servers with async and await
Scaling your servers with async and awaitStephen Cleary
 
Accelerate your web app with a layer of Varnish
Accelerate your web app with a layer of VarnishAccelerate your web app with a layer of Varnish
Accelerate your web app with a layer of VarnishJeremy Cook
 
jChaart - Web Dashboard Framework
jChaart - Web Dashboard FrameworkjChaart - Web Dashboard Framework
jChaart - Web Dashboard Frameworkoazabir
 
OpenROV: Node.js takes a dive into the ocean
OpenROV: Node.js takes a dive into the oceanOpenROV: Node.js takes a dive into the ocean
OpenROV: Node.js takes a dive into the oceanSimone Chiaretta
 
Design Practices for a Secure Azure Solution
Design Practices for a Secure Azure SolutionDesign Practices for a Secure Azure Solution
Design Practices for a Secure Azure SolutionMichele Leroux Bustamante
 
Frontend Application Architecture, Patterns, and Workflows
Frontend Application Architecture, Patterns, and WorkflowsFrontend Application Architecture, Patterns, and Workflows
Frontend Application Architecture, Patterns, and WorkflowsTreasure Data, Inc.
 
AngularJS - Architecture decisions in a large project 
AngularJS - Architecture decisionsin a large project AngularJS - Architecture decisionsin a large project 
AngularJS - Architecture decisions in a large project Elad Hirsch
 
Business Case for SharePoint and Office 365
Business Case for SharePoint and Office 365Business Case for SharePoint and Office 365
Business Case for SharePoint and Office 365Gregory Zelfond
 
SharePoint Folders vs. Metadata
SharePoint Folders vs. MetadataSharePoint Folders vs. Metadata
SharePoint Folders vs. MetadataGregory Zelfond
 

Destacado (20)

Scaling asp.net websites to millions of users
Scaling asp.net websites to millions of usersScaling asp.net websites to millions of users
Scaling asp.net websites to millions of users
 
10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websites10 performance and scalability secrets of ASP.NET websites
10 performance and scalability secrets of ASP.NET websites
 
ASP.NET MVC Performance
ASP.NET MVC PerformanceASP.NET MVC Performance
ASP.NET MVC Performance
 
Four Ways to Improve ASP .NET Performance and Scalability
 Four Ways to Improve ASP .NET Performance and Scalability Four Ways to Improve ASP .NET Performance and Scalability
Four Ways to Improve ASP .NET Performance and Scalability
 
Building Scalable .NET Web Applications
Building Scalable .NET Web ApplicationsBuilding Scalable .NET Web Applications
Building Scalable .NET Web Applications
 
Web api scalability and performance
Web api scalability and performanceWeb api scalability and performance
Web api scalability and performance
 
Updated Mvc Web security updated presentation
Updated Mvc Web security updated presentationUpdated Mvc Web security updated presentation
Updated Mvc Web security updated presentation
 
Architecting ASP.NET MVC Applications
Architecting ASP.NET MVC ApplicationsArchitecting ASP.NET MVC Applications
Architecting ASP.NET MVC Applications
 
JavaScript For CSharp Developer
JavaScript For CSharp DeveloperJavaScript For CSharp Developer
JavaScript For CSharp Developer
 
Scaling your servers with async and await
Scaling your servers with async and awaitScaling your servers with async and await
Scaling your servers with async and await
 
Accelerate your web app with a layer of Varnish
Accelerate your web app with a layer of VarnishAccelerate your web app with a layer of Varnish
Accelerate your web app with a layer of Varnish
 
Performance testing wreaking balls
Performance testing wreaking ballsPerformance testing wreaking balls
Performance testing wreaking balls
 
jChaart - Web Dashboard Framework
jChaart - Web Dashboard FrameworkjChaart - Web Dashboard Framework
jChaart - Web Dashboard Framework
 
OpenROV: Node.js takes a dive into the ocean
OpenROV: Node.js takes a dive into the oceanOpenROV: Node.js takes a dive into the ocean
OpenROV: Node.js takes a dive into the ocean
 
End to End Security with MVC and Web API
End to End Security with MVC and Web APIEnd to End Security with MVC and Web API
End to End Security with MVC and Web API
 
Design Practices for a Secure Azure Solution
Design Practices for a Secure Azure SolutionDesign Practices for a Secure Azure Solution
Design Practices for a Secure Azure Solution
 
Frontend Application Architecture, Patterns, and Workflows
Frontend Application Architecture, Patterns, and WorkflowsFrontend Application Architecture, Patterns, and Workflows
Frontend Application Architecture, Patterns, and Workflows
 
AngularJS - Architecture decisions in a large project 
AngularJS - Architecture decisionsin a large project AngularJS - Architecture decisionsin a large project 
AngularJS - Architecture decisions in a large project 
 
Business Case for SharePoint and Office 365
Business Case for SharePoint and Office 365Business Case for SharePoint and Office 365
Business Case for SharePoint and Office 365
 
SharePoint Folders vs. Metadata
SharePoint Folders vs. MetadataSharePoint Folders vs. Metadata
SharePoint Folders vs. Metadata
 

Similar a Tips and Tricks For Faster Asp.NET and MVC Applications

Asp.net performance
Asp.net performanceAsp.net performance
Asp.net performanceAbhishek Sur
 
High performance coding practices code project
High performance coding practices code projectHigh performance coding practices code project
High performance coding practices code projectPruthvi B Patil
 
Drupal performance and scalability
Drupal performance and scalabilityDrupal performance and scalability
Drupal performance and scalabilityTwinbit
 
Magento Performance Optimization 101
Magento Performance Optimization 101Magento Performance Optimization 101
Magento Performance Optimization 101Angus Li
 
Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011Timothy Fisher
 
Performace optimization (increase website speed)
Performace optimization (increase website speed)Performace optimization (increase website speed)
Performace optimization (increase website speed)clickramanm
 
Frontend performance
Frontend performanceFrontend performance
Frontend performancesacred 8
 
How to scale up, out or down in Windows Azure - Webinar
How to scale up, out or down in Windows Azure - WebinarHow to scale up, out or down in Windows Azure - Webinar
How to scale up, out or down in Windows Azure - WebinarCommon Sense
 
IBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the BoxIBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the BoxKarl-Henry Martinsson
 
C sharp and asp.net interview questions
C sharp and asp.net interview questionsC sharp and asp.net interview questions
C sharp and asp.net interview questionsAkhil Mittal
 
ASP .Net Core SPA Templates
ASP .Net Core SPA TemplatesASP .Net Core SPA Templates
ASP .Net Core SPA TemplatesEamonn Boyle
 
Developing High Performance Web Apps
Developing High Performance Web AppsDeveloping High Performance Web Apps
Developing High Performance Web AppsTimothy Fisher
 
Building high performing web pages
Building high performing web pagesBuilding high performing web pages
Building high performing web pagesNilesh Bafna
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19Vivek chan
 
Deploying windows containers with kubernetes
Deploying windows containers with kubernetesDeploying windows containers with kubernetes
Deploying windows containers with kubernetesBen Hall
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET PresentationRasel Khan
 

Similar a Tips and Tricks For Faster Asp.NET and MVC Applications (20)

Asp.net performance
Asp.net performanceAsp.net performance
Asp.net performance
 
High performance coding practices code project
High performance coding practices code projectHigh performance coding practices code project
High performance coding practices code project
 
Presentation Tier optimizations
Presentation Tier optimizationsPresentation Tier optimizations
Presentation Tier optimizations
 
Drupal performance and scalability
Drupal performance and scalabilityDrupal performance and scalability
Drupal performance and scalability
 
Magento Performance Optimization 101
Magento Performance Optimization 101Magento Performance Optimization 101
Magento Performance Optimization 101
 
Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011Developing High Performance Web Apps - CodeMash 2011
Developing High Performance Web Apps - CodeMash 2011
 
Performace optimization (increase website speed)
Performace optimization (increase website speed)Performace optimization (increase website speed)
Performace optimization (increase website speed)
 
Frontend performance
Frontend performanceFrontend performance
Frontend performance
 
How to scale up, out or down in Windows Azure - Webinar
How to scale up, out or down in Windows Azure - WebinarHow to scale up, out or down in Windows Azure - Webinar
How to scale up, out or down in Windows Azure - Webinar
 
IBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the BoxIBM Connect 2016 - Break out of the Box
IBM Connect 2016 - Break out of the Box
 
C sharp and asp.net interview questions
C sharp and asp.net interview questionsC sharp and asp.net interview questions
C sharp and asp.net interview questions
 
Ch05 state management
Ch05 state managementCh05 state management
Ch05 state management
 
ASP .Net Core SPA Templates
ASP .Net Core SPA TemplatesASP .Net Core SPA Templates
ASP .Net Core SPA Templates
 
Developing High Performance Web Apps
Developing High Performance Web AppsDeveloping High Performance Web Apps
Developing High Performance Web Apps
 
Building high performing web pages
Building high performing web pagesBuilding high performing web pages
Building high performing web pages
 
IIS 6.0 and asp.net
IIS 6.0 and asp.netIIS 6.0 and asp.net
IIS 6.0 and asp.net
 
13 asp.net session19
13 asp.net session1913 asp.net session19
13 asp.net session19
 
23 Ways To Speed Up WordPress
23 Ways To Speed Up WordPress23 Ways To Speed Up WordPress
23 Ways To Speed Up WordPress
 
Deploying windows containers with kubernetes
Deploying windows containers with kubernetesDeploying windows containers with kubernetes
Deploying windows containers with kubernetes
 
ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET Presentation
 

Último

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusZilliz
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 

Último (20)

AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

Tips and Tricks For Faster Asp.NET and MVC Applications

  • 1. Tips and Tricks For Faster ASP.NET and MVC Web Applications By Sarvesh Kushwaha
  • 2. 1. Static Resources should be Cacheable ;) Above code cache all static resources for 365 days.
  • 3. 2. Bundling and Minification Reduce the amount of data (CSS & JavaScript) sent across the network using Bundling and Minification in ASP.NET 4.5 . Bundling is merging all CSS files into one and same for JavaScripts file .This Reduce the number of requests to server. Minification is removing blank space b/w words and lines and more then that ;) . LINK : HOW TO DO IT
  • 4. 3.Use View State when its necessary Every control has ViewState in Asp.Net and ViewState is turned on in ASP.NET by default. ViewState is an unnecessary overhead for pages that do not need it. As the ViewState grows larger, it affects the performance of garbage collection. ViewState gets store in hidden field too many field can make a web page heavier and will cause rendering problem. So Disable ViewState for every control, untill you need it (have to keep data on post backs of a page). 1. You know you don't need ViewState for a textbox control and similar control untill you are performing textchange_event. So disable it by using EnableViewState= “false” for each one. 2. Disable ViewState at page level add in page : <%@ Page EnableViewState="false" %> . 3. Disable ViewState at Application level add in web.config : <pages enableViewState="false" />.
  • 5. 4. Use Effecting Paging • Bring small set of data at once ,show them using paging to render the page quickly. • Large set of data use stored procedure for page index data and filtering . LINK: HOW TO DO IT
  • 6. 5. URL Compression Now with IIS 7 we can do HTTP compression of data being send over the network . Add following Xml snippets in the web.config file under <system.webserver> node : <urlCompression doDynamicCompression="true" doStaticCompression="true" dynamicCompressionBeforeCache="true"/> • doDynamicCompression tells IIS whether it should compress dynamically generated content, i.e. content generated by your scripts (ASP, ASP.NET, PHP …). • doStaticCompression tells IIS whether to compress static files (PDF, JPEG …) ,those actually exist on the file system. • dynamicCompressionBeforeCache attribute specifies whether IIS will dynamically compress content that has not been cached.
  • 7. 6. Use Sprite Images use sprite images instead of using several images so at one download you can use several small images . Now we can make sprite images very easily using Some NUGET packages. Below are some :
  • 8. 7. Image Optimization • Normally images take largest percentage (size) in a web page. image optimization help us to increase performance . Using Asp.net Nuget we can optimize images : • Allocate space for image using <height/> and <width/> , it will let page rendering more quickly .
  • 9. 8. Always Deploy in Release Mode • At the time of deploying our main concern is performance , Debug Mode creates .pdb file and take some info generated by JIT to code address mapping . • Code is more optimized in Release Mode. • Less memory is used by the source code at run time in Release Mode. • Set debug=“false” in web.config for release mode.
  • 10. 9. Use client Side Validation At max one should use client side validation for application as it gives user a friendly experience and reduce the over head of post back to the server.Where secuirty is priority use server side validation .
  • 11. 10. Remove Unnecessary HTTP Headers The X-AspNet-Version, X-AspNetMvc-Version, X-Powered-By, and Server HTTP headers provide no direct benefit and unnecessarily used a small amount of bandwidth. • Removing X-AspNet-Version : Under <System.web> add this <httpRuntime enableVersionHeader="false"/> • Removing X-AspNetMvc-Version : Add this in Global.asax.cx file MvcHandler.DisableMvcResponseHeader = true; • Remove Server HTTP Header : LINK HOW TO DO IT • Remove or Edit X-Powered-By : IIS7 Manager > HTTP Response Header > Edit or Remove
  • 12. 11. Pipeline Optimization • There are many default HttpModule which sit in request pipeline and intercept each and every request. • Example If you are not using window authentication you don’t need window authentication HttpModule. Add following code in web.config : <httpModules> <!-- Remove unnecessary Http Modules for faster pipeline --> <remove name="Session" /> <remove name="WindowsAuthentication" /> <remove name="PassportAuthentication" /> <remove name="AnonymousIdentification" /> <remove name="UrlAuthorization" /> <remove name="FileAuthorization" /> </httpModules>
  • 13. 12. Use Content Delivery Network • Better if you download things from nearest server from your palace .its like travelling things from one country to another which takes times. If application has large number of images, CSS, JavaScript sending request for each of them and downloading them across the world will take significant time. • Content Delivery Network deal with static cacheable Content . • Bootsrap Used CDN for his latest release ;)
  • 14. 13. Dispose Objects Manually • Although Objects will be cleaned up when they are no longer being used and when the garbage collector sees fit. Always dispose an object which implements IDisposable ,to do so Use a USING statement to automatically dispose of an object once your program leaves the scope of the using statement. using (SqlConnection cn = new SqlConnection(connectionString)) { using (SqlCommand cm = new SqlCommand(commandString, cn)) { cm.ExecuteNonQuery(); } }
  • 15. 14. Effective use of Jquery AJAX in Asp.ne • Use ajax to download data asynchronously, which are not needed immediately like content of Accordion (Collapsed Panel) and tabs. • Don’t make too much ajax requests • Use ajax when its needed to load more data when user scrolls, when user is not scrolling there is no benefit to bring all the data at once.
  • 16. 15. Do use magic of Asynchronous Methods If your page needs to access multiple data sources , then use asynchronous methods to parallelize access to those sources . LINK : HOW TO DO IT
  • 17. 16. Turn off Tracing unless until its required because its keep track of the application's trace and the sequences. Under <system.web> node write following code: <trace enabled="false" pageOutput="false" /> <trace enabled="false" requestLimit="10" pageOutput="false" traceMode="SortByTime" localOnly="true"/> 17. Instead of Respons.Redirect() use Server.Transfer() when we want to transfer current page request to another .aspx page on the same server. it helps to reduce server requests. And optionally give us value of preserve query string and form controls values .
  • 18. 18. String Management : • Use += operator or String.Concat() when the number of appends is know and short . • Use StringBuilder object when number of appends is unknown. 19. Asp .NET literal and label are different • Literal just show that text they don’t add the extra markup. • Label add the extra markup <label><label/>. 20. Remove Blank Space and lines from HTML • Using Regular Expressions in VS2012 remove blank lines from .aspx and HTML ^(?([^rn])s)*r?$r?n • Use CodeMaid tool to remove spaces and more.
  • 19. 21. Use Performance Tools Correct code makes good performance • Backend performance Tools : DotNetMemoryProfiler, SQLServerProfiler • Performance Tools : • Static analysis tool : Yslow • Run Time Profiler : Speed tracer for chrome, Firebug for firefox, IE Developer tools • Others : WebPageTest , Page-analyzer , Pingdom • Monitoring Tool : Fiddler
  • 20. Developer Checklist Caching Client Side Validation Use ViewState if needed Dispose Objects ManuallyCDN Remove Unneccesary HTTP Headers Effective Paging URL Compression Pipeline Optimization Release Mode Images Optimization & Sprite Images Bundling and Minification Jquery Ajax Async and Await Turn Tracing Off
  • 21. Sarvesh Kushwaha | | | | | |