-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'dev' into RandomHelper
- Loading branch information
Showing
295 changed files
with
3,266 additions
and
2,930 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
docs/en/Community-Articles/2024-10-09-Cookies-vs-Local-Storage/Post.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# When to Use Cookies, When to Use Local Storage? | ||
|
||
![cover](cover.png) | ||
|
||
|
||
|
||
## Cookies vs Local Storage | ||
|
||
When you want to save client-side data on browsers, you can use `Cookies` or `Local Storage` of the browser. While these methods look similar, they have different behaviors. You need to decide based on the specific use-case, security concerns and the data size being stored. I'll clarify the differences between these methods. | ||
|
||
|
||
|
||
## When to use Cookies 🍪? | ||
|
||
1. **Server Communication (e.g: Authentication Tokens):** Cookies are ideal when you need to send data automatically with HTTP requests to the server, such as authentication tokens (JWTs) or session IDs. Cookies can be configured to be sent only to specific domains or paths, making them useful for session management. | ||
2. **Cross-Domain Communication:** Cookies can be shared across subdomains, which is useful when working with multiple subdomains under the same parent domain for microservice architecture. | ||
3. **Expiration Control:** Cookies come with built-in expiration times. You don’t need to manually remove them after a certain period that should expire. | ||
4. **Security:** Cookies can be marked as `HttpOnly` which makes them accessible **only via the server**, not via JavaScript! Also, when you set a cookie attribute, `Secure` it can be sent only over HTTPS, which forces enhanced security for sensitive data. | ||
|
||
|
||
### Considerations for Cookies | ||
|
||
- **Size Limitation:** Cookies are generally limited to around 4KB of data. | ||
- **Security Risks:** Cookies are susceptible to cross-site scripting (XSS) attacks unless marked `HttpOnly`. | ||
|
||
|
||
--- | ||
|
||
|
||
## When to use Local Storage🗄️? | ||
|
||
1. **Client-Side Data Storage:** Local storage is ideal for storing large amounts of data (up to 5–10 MB) that doesn’t need to be sent to the server with every request. For example; *user preferences*, *settings*, or *cached data*. | ||
2. **Persistence:** Data in local storage persists even after the browser is restarted. This behavior makes it useful for long-term storage needs. | ||
3. **No Automatic Server Transmission:** Local storage data is never automatically sent to the server, which can be a security advantage if you don’t want certain data to be exposed to the server or included in the requests. | ||
|
||
|
||
### Considerations for Local Storage | ||
|
||
- **Security Risks:** Local storage is accessible via JavaScript, making it vulnerable to XSS attacks. Sensitive data should not be stored in local storage unless adequately encrypted. | ||
|
||
- **No Expiration Mechanism:** Local storage does not have a built-in expiration mechanism. You must manually remove the data when it’s no longer needed. | ||
|
||
|
||
--- | ||
|
||
|
||
|
||
## Summary | ||
|
||
### Use Cookies | ||
|
||
- For data that needs to be sent to the server with HTTP requests, particularly for session management or authentication purposes. | ||
|
||
### Use Local Storage | ||
|
||
- For storing large amounts of client-side data that doesn’t need to be automatically sent to the server and for data that should persist across browser sessions. | ||
|
||
|
||
|
||
In many cases, you might use both cookies and local storage, depending on the specific requirements of different parts of your application. There are also other places where you can store the client-side data. You can check out [this article](https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Client-side_web_APIs/Client-side_storage) for more information. | ||
|
||
|
||
Happy coding 🧑🏽💻 |
Binary file added
BIN
+541 KB
docs/en/Community-Articles/2024-10-09-Cookies-vs-Local-Storage/cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
96 changes: 96 additions & 0 deletions
96
docs/en/Community-Articles/2024-10-09-NET9-Performance-Improvements/Post.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# .NET 9 Performance Improvements Summary | ||
|
||
With every release, .NET becomes faster & faster! You get these improvements for free by just updating your project to the latest .NET! | ||
|
||
![Cover Image](cover.png) | ||
|
||
It’s very interesting that **20% of these improvements** are implemented by **open-source volunteers** rather than Microsoft employees. These improvements mostly focus on cloud-native and high-throughput applications. I’ll briefly list them below. | ||
|
||
![From Microsoft Blog Post](cited-from-microsoft-blog-post.png) | ||
|
||
|
||
|
||
## 1. Dynamic PGO with JIT Compiler | ||
|
||
* ### What is dynamic PGO? | ||
With “Profile Guided Optimization” the compiler optimizes the code, based on the flow and the way the code executes. It is predicated on the idea that every potential behavior of the code will always transpire. | ||
|
||
* ### What’s Improved? | ||
The tiered compilation, inlining, and dynamic PGO are three ways that .NET 9 optimizes the JIT compiler. This enhances runtime performance and speeds up the time for apps to launch. | ||
|
||
* ### Performance Gains | ||
CPU use is lower during execution; therefore, **startup times are about 15% faster**. | ||
|
||
* ### As a Developer | ||
Faster, smoother deployments with reduced warm-up times... These enhancements reduce latency for applications with complex workflows, particularly in microservices and high-throughput environments. | ||
|
||
* ### How to activate Dynamic PGO? | ||
Add the following to your `csproj` file, or if you have several `csproj` files, you can add it once in `Directory.Build.props` file. Check out [this link](https://learn.microsoft.com/en-us/dotnet/core/runtime-config/compilation#profile-guided-optimization) to understand PGO. | ||
|
||
```xml | ||
<PropertyGroup> | ||
<TieredPGO>true</TieredPGO> | ||
</PropertyGroup> | ||
``` | ||
|
||
|
||
|
||
## 2. Library Improvements | ||
|
||
* ### What’s Improved? | ||
|
||
LINQ and JSON serialization, collections and libraries are significantly improved with .NET 9. | ||
|
||
* ### Performance Gains | ||
|
||
**JSON serialization** performance **increases by about 35%**. This helps with heavy data parsing and API requests. Less memory is allocated to `Span` operations as well, and LINQ techniques such as `Where` and `Select` are now faster. | ||
|
||
* ### As a Developer | ||
|
||
This means that apps will be faster, especially those that handle data primarily in JSON or manipulate data with LINQ. | ||
|
||
|
||
|
||
## 3. ASP.NET Core | ||
|
||
* ### What’s Improved? | ||
Kestrel server has undergone significant modifications, mostly in processing the HTTP/2 and HTTP/3 protocols. | ||
|
||
* ### Performance Gains | ||
Now, **Kestrel handles requests up to 20% faster** and **has a 25% reduction in average latency**. Improved connection management and SSL processing also result in overall efficiency gains. | ||
|
||
* ### As a Developer | ||
These modifications result in less resource use, quicker response times for web applications, and more seamless scaling in high-traffic situations. | ||
|
||
|
||
|
||
## 4. Garbage Collection & Memory Management | ||
|
||
* ### What’s Improved? | ||
NET 9’s garbage collection (GC) is more effective, especially for apps with high allocation rates. | ||
|
||
* ### Performance Gains | ||
Applications experience smoother **garbage collection cycles with 8–12% less memory overhead**, which lowers latency and delays. | ||
|
||
* ### As a Developer | ||
The performance will be more reliable and predictable for developers as there will be fewer memory-related bottlenecks, particularly in applications that involve frequent object allocations. | ||
|
||
|
||
|
||
## 5. Native AOT Compilation | ||
|
||
* ### What’s Improved? | ||
Native AOT (Ahead-of-Time) compilation is now more efficient by lowering memory footprint and cold-start times. This leads to better support for cloud-native applications. | ||
|
||
* ### Performance Gains | ||
Native AOT apps now have faster cold launches and use **30–40% less memory**. This improvement focuses on containerized applications. | ||
|
||
--- | ||
|
||
|
||
|
||
**References:** | ||
|
||
* [Microsoft .NET blog post](https://devblogs.microsoft.com/dotnet/performance-improvements-in-net-9/). | ||
* [What’s new in the .NET 9 runtime?](https://learn.microsoft.com/en-us/dotnet/core/whats-new/dotnet-9/runtime#performance-improvements) | ||
|
Binary file added
BIN
+110 KB
...les/2024-10-09-NET9-Performance-Improvements/cited-from-microsoft-blog-post.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+441 KB
docs/en/Community-Articles/2024-10-09-NET9-Performance-Improvements/cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.