Implementing Advanced RESTful Concerns With ASP - NET Core 3
Implementing Advanced RESTful Concerns With ASP - NET Core 3
Course Overview
[Autogenerated] Hi, everyone. My name is Kevin. Welcome to my course Implementing
and fast stressful concerns at a speed of net core tree. I'm a Microsoft M v P m
freelance solution architect currently focused on security and building a P I. In
this course, we're going to learn how to implement advanced stressful concerns with
air speed up that tree. Some of these concerns might not be so obvious at first,
but implementing them will lead to a better, more evolved will a p I so off the
major topics that we will cover includes Beijing sorting and data shaping.
Implementing Hato s support or hyper media as the engine of application State
advanced counter negotiation scenarios to improve the reliability off you're a p I
and cashing and concurrency by the end of this course will know all about arrest
constraints and you'll end up with a level tree rest ful FBI, which is the highest
possible level of maturity before beginning the course. You should be familiar with
the SP dot net core and C sharp. I hope you'll join me on this journey to learn how
to improve your weapon. FBI with implementing viral stressful concerns with the
hospital that court recourse at plural side
Tooling
[Autogenerated] will use Visual Studio 2019 for the team was in discourse to use
dot net core tree you need version 16 point tree or better if you haven't got a
name is D analyzed since you can now look to free Community Edition. But that
doesn't mean that you need visuals to your 2019 to follow along any I d. That
supports free work, version and or application type you're working with can be used
depending on your needs. That might be visual studio coat, visual studio for Mac or
other ideas like jetbrains Rider or Sublime. However, Visual Studio 2019 does offer
the best stooling at the moment off. Recording our co two targets Don't net core
tree. If you haven't got that yet, you'll have to dilute it. You can find it at the
______ on screen. Simply download and install the full 3.0 as decay and you're good
to go. That's it for the i D and dot net core versions. What will you Some other
tools as well to create requests to our FBI and to see the response messages will
use postman Postman is free tool you can use to amongst other things, create and
send http requests and inspector responses bundled together with the exercise files
are all http request will send in this course So you can just import having postman
and use them. Save you a bunch of typing. You'll need a browser of choice as well.
And that's about all that's needed to get started. As usual, the exercise files can
be found. Fire the exercises. Stop on the course page The Post. My requests are
gonna file in the root folder off the day. Most off this marshal, it's named
Implementing Advance Stressful Concerns. Don't Postman Collection as an alternate
if you can also get the start of solution and finished sample from I get up, The
postman request can be found in the root folder here. A swell. Let's have a look at
the _____ application we're going to use
Recapitulating REST
[Autogenerated] rest is an architectural style constrained by a set off
constraints. These constraints can be seen as design decisions. Each of those can
have vote positive and negative impacts. So for these constraints, the benefits are
considered to outweigh the disadvantages. There's quite a few constraints to a dear
to you can see them on screen. All of these have been explained in my building
arrest for a P I with the s p dot net court recourse. But not all of them have been
implemented yet. What we will implement in this court is related to two off these
constraints. Do you any form, interface, constraint and the casual constraint?
Let's have a look at those uniform interface constrained states that the A P I and
a P I consumers share one single technical interface or contract. As we're
typically working with the http protocol is, interface should be seen as a
combination off resource. Your eyes. In other words, where can you find your
resources? Http methods, In other words, how can we interact with them? For
example, true get or both etcetera and http media types like Application Jason
Application and XML that are reflected in request and responsibilities. This is
also called the contract Between Client and A P I and the thigh Third base is the
more reliable and evolve herbal client, and a P I become that's pretty. Three parts
on the slide in this course will dive deeper into the last part of the contract
payload defined by media types. We will learn that application. Jason doesn't
guarantee a tight contract which isn't that good in regard to reliability and
evolve ability. We will improve on that with advanced quantum negotiation and
vendor specific media types. Toe get to such a well designed technical interface
between client and FBI. Do you reform interface constraint is divided into four sub
constraints. First up constrained is the identification of resources of
constraints. It states that individual resources are identified in requests using
your eyes. Resources themselves are conceptually separate from the representations
that are returned to the client in our day. Most who will work with altars and
courses on all the resorts could be found that a B i forward slash alters forward
slash your i d. But that resource is conceptually different from the presentation
off that resort that's returned in the response to representation could be Jason in
most cases, but it can also be expelled, and other types were also possible. This
is mostly related to the first part of the contract. Seconds up constraint is the
manipulation off resources through the presentation Subject Street. This one states
that when a client holes or the presentation of a resource, for example, Jason or
XML, including any possible metal later it must have enough information to mollify
or the lead to resort on the server, provided it has permission to do so that is
thus related to the payload part of the contract. The third sub constraint is the
self descriptive message constraint. This one states that each message must include
in love information to describe how to process the message. When a consumer
requests data from an A p I, we send a request message, and when he gets back data,
that's a response message, and such a message is headed on a body. If requests body
contains cheese from the presentation of resource, the message must pacify that
fact in its headers. By including the media type like application, Jason like that,
the correct parts that can be invoked to process the request body and it can be
serialized into the correct class. Same for the other way around. This constraint
do is related to the payload part of the contract. All these constraints have
already been implemented in the devil. The last one hasn't been, and that's hate
us. It means hyper media as the engine of application state dis constraint balls
down to creating a self documenting A P I. And the documentation can then be used
by client applications to provide functionality to the user. It's not an easy
constraint to understand it's mainly related to the payload part of the contract.
But as it describes the AP, I it is in a way also related to each other part of the
contract. There's two full modules dedicated to it in this course. It offers some
really interesting possibilities, like operating a business rule at a pea eye
level, which the Kyle can learn about without having to update your clients
version. I think it adds a lot of value to an A B I. Now, looking at this slide, it
seems like there's a lot of attention going onto the payload represented by media
types like application chase. There's a quote by really feeling, and that's the guy
who invented the term rest. And who described the architectural style that hidden
stores. Why, that's the case. It states that arrest a p. I should spend almost all
of its descriptive effort in defining the media types used for representing
resources. Well, that's interesting. If application Jason would be the only media
tie abused, there wouldn't go a lot of effort into describing it right. That's
because arrest fel a P I and regular Web A P I. R. Two different beasts. We will
learn a lot about his media types how to create him, why they are so important
during the course onto the next constraint. The casual constraint this one states
that each response message must explicitly state if it can be cashed or not. It's
quite easy to a deer to simply ensure each response states that it cannot be cashed
and we're compliant. But where's the fun in that? Most applications require
cashing, and that's exactly what we will implement In this course like this. We can
eliminate some client server interaction and at the same time prevent clients from
re using out of date data. Http. Cash, sometimes called the old the grail of
cashing with e tax is the typical standards used in arrest architectural system. So
they should give you an idea what this course is about. But there's more. We're
kind of getting ahead of ourselves next to a dearing. To these constraints, AP eyes
often need additional functionality. Think about paging, sortie and data shaping.
Let's continue with implementing paging support for our A B I.
Summary
[Autogenerated] paging can be very good for performance. If don't correctly, we
should pause The Babe sighs and page number fired a Query Street. Think about
limiting the page size that's passed in to avoid consumers requesting one page with
a 1,000,000 records. In other words, make sure to provide default values for page
size and page number. Also, imagination. Meta data belongs in a custom header. When
paging, it's important to send page size and number two the underlying store like
that. Only the requested page is returned from the store, thanks to deferred
execution to principle that allows us to keep building a credit before executing
it. We can use, Skip and take statements for that also, page by default to avoid
performance issues when the collection grows. For that, we created page list class,
which can easily be reused for other resources. Lastly, it's important to return
pagination medal later, so the consumer knows how to navigate to previous or next
pages. And how many records aren't in the database that meta data belongs in a
custom header, for example, X pagination. That's it for Beijing. There's another
piece of function out of the awfully quiet for the FBI's sorting. We're covering
that in the next module
Shaping Data
Coming Up
Data Shaping Resources
[Autogenerated] Let's talk about shaping resources. Word kind of gives away what it
does. This principle allows the consumer of the A p I to choose the fields off the
resource. Does that have to be returned? So rather than returning all properties
off, say, on altar consumer oven, a p, I might only need to know the idea. And the
name data shaping allows for this by looking at a Fields credit string parameter
off which value is a comma separated list off field names. Implementing
functionality like this can be very good for performance. In case of our older, the
impact will be quite small, But just imagine a resource with 30 properties off
which the consumer needs a collection off 50. But he only needs to feels without
data shaping 1500 property values would have to be sent to the consumer. With eight
are shaping on Lee, 100 will be sent That does have a noticeable impact. What's
important here justice for filtering and sorting is that this field level selection
isn't level off the resource field names past in US value for the fields. Credit
string parameter should exist on the resource. So for our order. The field level
selection on age is foul it as the altars resorts has an age, but one on date of
birth is not fell. It as an alters resort doesn't have that The date of birth is
defined on the entity, not at level of the outer facing contract. Let's have a look
at how we can implement this.
Summary
[Autogenerated] when implementing data shaping functionality, it's important to
keep a few things in mind. Data shaping can only happen on resource fields.
Northern fields that lie beneath that layer once the glasses shaped, it's no longer
your original diet. Working with expand Oh, object makes it easy to create these
types of objects for performance reasons. Don't reuse the same method for shaping
collection resources. Then you would use for shaping single resources. Fields
parameter must be returned in page nation links and adults relate to wrong input or
consumer letters and should just be returned as a Level 400 ever. For example,
about request, we mentioned Hato as a few times we can use it to a dear to the
manipulation off resources by our presentations constraint, and additionally, we
learned that it can also be used for pagination medal later, which will tie into
the self descriptive message constraint. So it's about time we cover that right
onto the next module, learning and implementing Hato US
Summary
[Autogenerated] this module was focused on he to us. Hyper media like links Dr Have
to consume and use the A P I and the functionality off the consuming application.
It's st A good example would be a piece of functionality that allows someone to
make a course reservation without hate us to consumer of the A P. I must know how
to do that, typically from documentation, so it needs intrinsic knowledge of the A
P I. Even if functionality and business rules change, client applications won't
break as they need to inspect the links they get back from the A p I. These links
are included in the response body. We implemented this using dynamics, but even
though we kind of have hate us support now, we ended that last name or with a bit
of an issue. We're asking for media type application, Jason, but we're returning
links and sometimes even an envelope that can't be right. So that brings us to a
perfect use case for using media types correctly instead of just returning anything
as long as it's in Jason formal. When asking for application. Jason in the next
module, we will learn all about it
Tightening the Contract Between Client and Server with Vendor-specific Media Types
[Autogenerated] We've just used our first fender specific media type and
immediately saw the advantage of it. But there's more we can do these days. More
and more a p. I started using vendor specific media types. Let's take unaltered as
an example, we're currently using the order with concatenation name and age as to
return type. When getting old. We assumed that that stood a presentation most
consumers would want. But is that really the case? You could imagine that some
consumers might want the order like that, but others might want the altar with
first name, last name and date of birth fields. Those are just do the presentations
off the same altar. Yet we can't request these when we use application. Jason, our
FBI doesn't know which way presentation to return. It just knows we want it in
Jason, Former, we found the specific media types. We can't specify the exact time
we could create to render specific media types. Fear needle, Marvin the altar. Not
friendly for the friendly, formal with age and name and V indeed, old Marvin the
daughter. Don't fool for the presentation with first name, last name and date of
birth, this Titans to contract between client and server and thus makes our system
more reliable and evolve herbal. These are what are called semantic media types,
media types that tell something about semantics off the data. I what it means a
vendor specific media type can does be a semantic media type if it's used in the
way we just described. But how do we combined that then, with hate OS leaks
application via needled Marvin Potato us would give us an alter the presentation
with links and the other media types Wouldn't we could fix that by creating new
suffix. Close Jason. He's a suffix. We can add a plus. Ito s suffix like that.
Consumers can ask for the Friend Leader presentation without leads the friendly,
the presentation with links, the full representation without links or the full
representation with legs. This is something you can see in the wild from time to
time. But according to the media time definition, there should only be once off
exper media type. Next to that, only officially registered suffixes should be used.
So while the examples we just looked into will work, they do violate a few best
practices in that regard it's better to add the hate US part to the type itself. So
like that we can use this media type for the friendly. The presentation. Without
links, we can use another one for the family. The presentation with Wings, one for
the full representation without legs and, lastly, one for the Fuhrer presentation
with links. Important to know is that we should always return a default as well. I
eat when the user requests application. Jason, Let's say that that's our friendly,
the presentation without Heat, West Wings. And, of course, we also still want to
support via need dot Marvin Potato s. Well, that seems like quite a bit of work,
but it's actually not as much work as it seems that's here. We can implement that
in a Dave O
Demo - Tightening the Contract Between Client and Server with Vendor-specific Media
Types
[Autogenerated] in this demo, we'll add support for vendor specific media types
when getting an altar. Let's start by adding a class for our full old. We'd like to
take the model folder and we had a new class. Let's name it. Alter Full video. This
one contains idee first name, last name, date of birth and main categories. So just
like the entity but without the courses, let's add a mapping forties. For that, we
open the altars profile and we had a new mapping from source type and the's No
daughter to destination. Dive models don't alter ful detail. All right, let's save
that and back to our get alter action. We're already accepting a media hype and
checking whether it's fell it. We did that in the previous table, so we have a
party media type. The first thing we want to know is whether Ling should be
included for that. We have to look at the subtype without suffix. That stuff takes
that's plus Jason. So that's the part we're ignoring. Once we have that, we check
if it matches. Hate Wes, and if that's the case, we can safely create links. So we
added variable to store these links, and if we need to include them, we create him.
Then we need to check. If the full alter has been requested, we need to be able to
differentiate between the full altar and the friend. The order or application.
Jason. As these two are the default, we can simply check for the full alter part of
the media type. So with a little bit off string manipulation, we can quite easily
get to that. It's either the subtype without suffix or that same subtype without
suffix without hate us part. If that matches VND, don't Marvin the daughter, not
fool. We know we have to return unaltered. Full video. In any other case, we want
to return the friendly. Alter the presentation so the map and shape potentially
include links and return it our code from the previous day. Moist, no longer
necessary. That part is handled by the new coat. We dote. All right, let's give
that a try. Let's try getting a full order. No links included. We hit that for 06
Not acceptable ever again. That makes sense because there isn't a single output for
motor that supports this media type. We could go ahead and add global support for
this. That will work. But there's another way back to our coats. What again?
Looking at the gets alter action. A few clips ago, I mentioned that there was a way
to couple media types to specific resources. By applying to produces attributes, we
can restrict the media types and action can produce. I return. And that makes sense
for our use case, much more sense than supporting and globally. We are pretty
strict in what we want to return. We don't want to. For example, let these action
return something when say, fi nd does Marvin Look course was set us value for the
accepted. Currently, that would work if, via Little Marvin, of course, was globally
registered. So let's all of these tuitions You won't go. We applied to produce is a
tribute to our get alter action, and we passed through all the types allowed for
this action. Be careful with this, though. This is Freddie restrictive. Any type
not in this list will return a four or six all acceptable, but depending on how
strict you want to be. That's exactly what we want. A quick dip to avoid
duplication you could also apply to produces attribute that controller level or
even globally. It's just a filter so it can be added to the global filter
collection if needed. It's not applicable for the demo, but it might come in handy
in a real life project. Let's give this another try. Let's try getting a full altar
without legs. That's request. We still have lined up and there we go. There's our
full altar. If he changed the accepted her Tuvia leader ____ in the daughter. Don't
fooled off Hato s plus Jason. We should get the full alter, including legs. Let's
try that years or older, including the links. And let's try the same for the
friendly. The presentation. We try to get it without links by passing through an
except other with value application VND not Marvin the daughter, not friendly.
Bless Jason that send it. Here's our friendly. The presentation with a name and an
age instead off first name, last name and date of birth fields. And now let's try
getting it with links, and there we go. Now, if you'll remember, we should also
support application Jason and our coat does just that Let's try getting an altar
within. Accepted her application. Jason. This is a request from a previous table.
Let's send it again. And there we go. This still works. This returns to friendly
the presentation without legs. That's our default. Lastly, let's try to request
from the previous demo again. This media types simply states that we want to
include links without being too specific on the type. It should still work. Let's
give that a try, and there we go. That still works. It returns the defaulter
presentation off the order. That's the friendlier presentation, and we get links as
well. So far, so good we're not going to implement is on the altars resource. But
it's exactly the same principles that you have to follow to do that. That's it for
output. But what about import? In other words, what about allowing a consumer to
input data in different forms? Let's learn about that next
Summary
[Autogenerated] in the last two modules he focused on Hey, tow US and media types
Correct use of these often separate AP ICE that intend to be rest ful from truly
rest ful AP eyes. But in reality, what we really learned about was evolve ability.
These were also the modules in which we learned that building a rest ful system is
a lot different from building a standard Web A P I. As we learned a custom media
types should be used when a consumer wants to include his hate West links in the
response body, as it's a different representation of the resource. These media
types are key principle and building rest sleepy eyes. What we did up until this
module, using application Jason for a resource of presentations actually isn't
truly correct. Unaltered. A presentation with first name, last name and date of
birth is different from the presentation with name and H. These are different media
types. We shouldn't use application Jason for that. Instead, we should create
separate media types. By doing so, we're attaching semantics, I meaning to what a
client can request storybook that leads to better revolve ability and reliability,
and that then let us tow adapting to change inversion ing. We learned that we
should use hate us for changes to functionality and business rules, and that until
the gold on demand constraint is feasible, we should use version media types
building truly rest ful. FBI does take a bit of work, but the evolve ability it was
designed for this word it and we're talking system that are built to adapt to
change over years or even decades and not months. That's it for hate, Westen media
types. If used correctly, it can be a tremendous addition to an A P. I for more
constrained remains the catchable constraint. Another big one. We'll look into it
in the next few modules.
Cache Types
[Autogenerated] So in. Http there are tree cash types. One is the client cash or
browser cache. It lives on the set of the client application. A browser is an http
clients, but we can extrapolate that if for building, for example, mobile client
application with salmon. That client application, which communicates with the A p I
threw an http Klein instance, will often have a private cash. It's called private
because the resort has can be shared with anyone else. They're kept on the client
for each consuming instance. So good examples are a cash on your mobile device, but
also a cash in local storage. For an angler app. The second type is the Gate three
cash. This is a shared cash to resources. It caches are shared across different
applications. This type of guys, she was on the server side. All the names for
this, our reverse proxy caches or even http accelerators. This is does the cash
time that's often putting from the baby eyes. The third type is the proxy cash.
It's also a shared cash, but it doesn't leave after consuming side nor outside of
the FBI. It lives on the network. They're often used by large corporations and ice
piece to serve thousands of users. If you ever had to change your browser settings
and input a proxy address, well, you've used one of these regard. Focus on this
last well as it's out of our control. Most of the time combinations are used a
private kasher consuming side combined with the gateway cash that server side and
maybe even a proxy in between, depending on whether or not the response is casual
and where it is allowed to be cashed, we might are back and right up to the
database. We might hit a proxy or gateway cash without having to communicate with
our database. Or we might only hit a private client side cash A living in
communication between client and server completely. Microsoft has a piece off
middleware for the shared gateway type cash response. Cashing a tribute Emily
where? Let's look into that
Demo - Using Cache Profiles to Apply the Same Rules to Different Resources
[Autogenerated] in this demo will learn how to use cash profiles so we can easily
apply the same rules to different resources. We're looking at the start up costs ad
controllers except a set of action. And on that set of action, there's a list of
cash profiles by calling Add on its we can have a new one. Cash profiles is
actually a dictionary, so we need to give it a key. Let's say, 240 seconds cash
profile As value we add to the actual cash profile, we give the duration of 240
seconds double of what we had before. That's a this. Let's continue to the courses
controller. Cash profiles can be applied to the response cash attributes and that
can be used at control or an action level. So let's apply our cash profile at
controller level. We apply a cash profile by setting the cash profile name to the
key. We gave the cash profile in the Cash profile dictionary as response Cash
attributes at action level over I toes at controlled level. They should mean that
when we get one specific course, we should still see a maximum age off 120 seconds.
However, when we get the courses, we should see 240 seconds that's built. Alice.
Give this a try. Let's send that request to get a course again. And if you look at
the cash control heather, we see a max age of 420. Now let's get the courses. And
if you look at the response headers, we see a maximum age off 240 seconds, as
expected. So that's pretty cool, right? But how does it actually work? I What are
the mechanisms that decide on whether something is served up from a cash store or
not? Let's have a look at the exploitation and validation models.
Expiration Model
[Autogenerated] the expiration model is away for a server to say how long requested
resource so response message is considered fresh. Akash Condensed store this
response so subsequent requests are served from the cash as long as it's still
fresh for this dude responds headed for used. The expired headed is the simplest
well, it contains an http date stating at what time responds expires, but that has
a potential issue. The clocks must be synchronized between cash and server. It also
offers little control over what types of responses can be cashed when and where
it's been superseded by the Cash Control header, which addresses these limitations.
In the example, you can see Akash Control Head of values Public Max H equals 60.
This response headed contains two directives. Max, age and public. As we learned
during the demo Max Age, States response can be cashed for 60 seconds. It also
means that the clock sink is no longer an issue to recapitulate public states. That
it can be cashed by both shared and private cash is so the server can decide on
whether or not the responses even allowed to be cashed by a gateway. A proxy cash
those are shared or at all, for that matter, disquiet a few possible directives
next to public and max age. You can find those at link on screen. They're divided
between directives that can be sent in a request so kind can decide on some
explanation related values and directives that can be sent in response so the
server can decide. We will look into these later all, as some have to do with
expiration and others with validation. So we have to cover that. First, let's have
a look at how this exploration model works. Imagine we have a client application,
consumer of our FBI, Akash shared or privates and our FBI. The back end. The
application sent a request to get the orders. This request. It's the cash. There's
no cash version of the response available. So the cash forwards the request to the
A p I. Or maybe I should then return the response, including cash control. Heather
that, in case of our example, states that the response will stay fresh for 1800
seconds or half an hour. That hits the cash Egan and the cash then forwards it to
the consuming application. But at the same time Stores copy off this response 10
minutes later. Our absence. A request to the altars resource. Again, we get the
cash, and this time the cash is a response. It hasn't expired. It sends Baghdad
response, including an age header in our case at ages 10 minutes or 600 seconds. A
request to the back and distrust. Eliminate only when the cached version reaches
expiration time, which means it becomes still the cash will hit the back end again.
If this cash is a private cash like one that lives in local storage for the
Wrangler up or on a mobile device for a mobile app, that's where it stops. But if
we assume that the cash is a shared cash leaving on the server, for example, it's a
bit different eminence Later, subsequent requests from another instance of our
client application or another client application that consumes or a P I to a P. I
ordered it will hit that cash and assuming the response hasn't expired, it will
serve that up from the cash this time within each other of 20 minutes or 1200
seconds. So there's again no communication without a P I if it's a private cash
subsequent request, save bandwidth and reduce requests to the A P I as long as the
responses and expired. We don't need to server anymore for requests coming from the
same client instance. But of course, when different clients send the same request
they still hit are back, and they all have their own private cash. If it's a shared
cash, subsequent requests don't save band with between the cash in our a B I, but
it does drastically eliminate requests to R A P. I imagine there's thousands of
simultaneous consumers over a P I. The 1st 1 It's the A P I. All the other ones hit
the cash, which also means a lot less code has to be executed. The number of times
the databases to be accessed goes down drastically and so on. This is a pretty good
reason to combine a client, cash and a shared cash. The expiration Wallace nicely
supported by what refused about the Lao response cash attributes and response
cashing little where, but looking at exploration like this is typically only good
for content that's quite static images, webpages, master data and so on. So it's
actually not that could've fit for a P I psych hours off which the data can
dynamically and often change, even altered, is added by one of our 1000 consuming
applications. The altars response that's cashed isn't correct anymore. Worst case.
With an explanation of 30 minutes, we end up with as good as half an hour of
invalid data, and that's what the validation model takes care of. Let's have a
look.
Validation Model
[Autogenerated] validation issues to validate the freshness of a response that's
been cashed when a cash has a stale entry that it would like to use is a response
to a client's request. It first has to check with the origin server or possibly an
intermediate cash with a fresh response to see if it's cashed. Entry is still
usable to be able to validate, we need something to well validate against, and
that's a validator. Thes validators are used to check if they represent the same or
different responses, and that's a combination of feathers and body. There's two
types of validators strong validators and weak validators. A strong validated
changes if the body or headers off the response change. The typical example of such
a validator is an attack or ended. The deck sent true the feedback responses. So I
need Act is an opaque identify. A signed by a Web server to a specific version of a
resource. Strong validators can be used in any context with cashing, but also for
concurrency checks with updating resources as well. Learn later on in the scores a
week. Validator doesn't always change when the resource changes. It's up to the
server to decide when a change is warranted. For example, on Lee change on
significant changes and not one less significant aspects change. A typical example
is the last modified response. Heather containing the time when the resorts was
lost. Mollified. These are implicitly week. We've got a possible one second gap.
Now it is possible to make this strong by adhering to a set of rules, like an
additional date value on cash gentry. That's at least 60 seconds after the last
modified eight amongst others. But that would lead us too far. So let's treat the's
s weak. But even then, the clocks must be synchronized. So it's all for the same
issues as the expire center, which is why I e tax are better options. And there's
something like Wiki attack us. Well, when it's post fixed with W forward Slash,
it's treated as being weak. It's up to the server to decide this when an end of the
attack is in this former. It doesn't necessarily change if the response changes
week. Validators can only be used when an equivalent resources good enough, but
equality isn't required. I you don't always need the most recent first simple get
requests for cashing, for example, are allowed. They can be even more efficient.
Even equivalent version would be okay for a client. But anything else isn't. We
cannot use these if we need to be sure that different versions are equal. Nor for
concurrency checking. In other words, in case of a resource we can get a swell as
update week back is a bad idea. The HDB standard advises to send boat attack and
last modified headers if possible. This immediately poses a problem for us. The
response. Cashing attributes refused up until now does not support E tax, so we
cannot use the best practice when working with the attribute in. The next model
will learn about different approach that does allow working with the tax. For now,
let's have a look at how this validation model works, he began. Got a client
application consumer of our FBI, Akash shared or private and our FBI the back end.
The application sends a request to get the altars to request chits to cash. There's
no cast first of the response available, so the cash forwards request to our a p I.
Our FBI returns response. It includes an e Tak and lost modified header that's sent
to the cash again. Which forwards? It's too consuming application, but at the same
time stores a copy off this response. After that, our absence request to the altars
results again reminisce. Later we hit the cash, but we can't be sure that response
has been cashed is still fresh. There are no cash control headers to check for this
in our example. So the cash has to check this with the server, the A p I. It does
this by adding request headers if no match said to the e tak value and if modified,
since which is set to the last mollified value off the cash response. These make
this request conditional Serve receives this request and it checks thes headers
against validators. It holds or generates for that request. If this checks out, the
server does not have to generate a response. It sends back a trio for not
mollified, after which the cash can return the cash response with the original last
modified header. If it supports, last modified. If the resource has been modified,
the AP, I will, of course, have to generate a new response If this cash is a
private cash, that's again where it stops. Let's assume the cash is a shared cash,
a subsequent request ____ minutes later from another instance of our client
application or on other client application that consumes what a P I will hit that
cash. The cash will set if modified, since Heather, to the last mollified value of
the cache response and if no match to the attack value if it's still checks out,
response still does not have to be generated. In other words, with validation, the
same response only has to be generated ones. If it's a private cash, subsequent
requests save bandwidth. We have to communicate with the A P I, but we don't need
to send over the full response from the A P I only a trio for not mollified
responses to see if it's a shared cash. Subsequent requests don't save band with
between the cash and the blind, but it does save battles with between the cash in
the A P I. As the server doesn't have to regenerate responsive, it's still valid,
so it doesn't have to send over a responsibility to the cash. In contrast to the
exploration model. The validation model is not something that's correctly supported
by the response, cash attribute and response cashing will wear. But don't worry.
We'll look into a solution in the next module. So two different strategies to
different uses more often than not, exploration and validation or combined. Let's
have a look at what that looks like. And let's immediately make a separation
between private and shared caches that start with the private cash. We've got a
response to the orders resource cash. It has a gash control header for explanation
checks and the last mollified and eat accounted for validation chicks, a new
request descent. And as long as the response hasn't expired, the cast response can
be used. This reduces communication with the A P I, including regenerating
responses, and it reduces vantage requirements. We don't even hit the A P I. Once
it expires. We do hit e a P I. If he only have expiration checks, this means the
AP. I would have to regenerate response. But with the validation checks we can
potentially avoid is because it's not because of response is still there. It's
invalid. The A P I checks the validators and If the response is still valid, it
sends back it for you or for not mollified bad. With usage and response
generations, there's potentially reduced even more because even expired response
doesn't necessarily result in the response body. If the cash is shared, the cash
responses used as long as it hasn't expired. This doesn't result in bandit
reduction between client and cash, but it does result in bandit reduction between
cash and a P I, and dramatically reduces the amount of requests to the A P I a lot
more than a private cash. As this one is shared across potentially unlimited client
instances, it responds, expires. The cash must communicate with the A p I. But
here, us well, that doesn't mean the response has to be regenerated. If elevation
checks out, a trio for not mollify descend to the cash without responsibility. That
potentially reduces bandwidth usage between cash in a B I and responsibly
generation. The new response must still be sent to the client from the cash, of
course, combined these to a private cash for each client instance and a shared cash
at server level, and we reach the holy Grail of cash in That's it for the
exploitation of validation Muggles. There's one more thing to cover before we go
into the next model to learn how to work with the validation model and e tax. As we
learned a bit earlier. There's quite a few cash control directives available that
control cashing Bo that request side and response side. Let's have a look at those.
Summary
[Autogenerated] we started learning about cashing in this module. One of the rest
constraints is that each response must state whether or not it can be cashed. We
looked into the HDP cashing standards, and that was quite a lot of information.
Cashing really isn't a simple subject, but the important parts to remember our that
the cash itself can be private or shared and depending on the type of model, can
reduce bandwith requirements and or network round trips. Those models are the
exploration and validation models. We use the exploitation model to allow the
server to state how long response is considered. Fresh for that use the cash
control header. The validation model is used to validate the freshness over
responds that's being cashed. It does this with the help off. Strong validators
likey tax or weak validators like lost modified dates or wiki tax response. Cashing
attribute is used to control the cash control headers on the response message. The
Response Cashing mill, where acts as a cash store. It's this component that
effectively stores the responses and potentially serve them up from the cash. But
their attributes limitations. It cannot generate strong validators like an attack
which limits. What we can do with it and the cash store has some limitations as
well in the next module will solve these issues.
Supporting ETags
[Autogenerated] as we learned the previous model. The validation model requires
validator dates are weak validators e tax or strong validators. Such a strong
validators preferred over the weak. One response cash attributes doesn't generate
those. So we need another component that will to make our lives a bit easier. I
created such a component Marvin, not casual headers you can find. Don't get up and
you get It's a piece of a Speedo net. Core Middle. Where, that adds HTTP cash
handers. Two responses, like cash control, expires E tak and last modified. It also
implements cash exploration and validation models. Just as we learned in the
previous model. It can be used to ensure caches correctly cash responses and or to
implement concurrency for as based AP ice. Using e tax concurrency is covered in
the next model. It's important to know that the military itself does not store
responses. I wanted to create something lightweight that could easily be plucked
into the request by plan for just one purpose, correctly generating these headers
so Akash can check for exploration and returning a trio for not modified response
message and preconditions and potentially returning for 12 Precondition failed
response the last one is often used for computers he checks. Let's start by adding
it to a project to generate e tax.
Summary
[Autogenerated] this model was focused on the validation model off the HDP Kashtan.
For that, the best option is to use a strong validator like an attack. We added
Marvin, not casual headers to our FBI so eat ex can be generated By doing so. We
ended up with an A p I that fully supports http cash, which means it correctly
generates Heather's validators and implements expiration and validation models so
it can correctly respond when Akash sends a request. But we didn't have a cash
story yet. Response. Cashing Delaware isn't a good option for anything but trivial
cases. Shared cash stores are seldom something that you'd implement that
application level. They are full blown cash servers in their own right. Good
options are varnish, Apache traffics over or squid. Another option is using a seedy
end, which already implements one of those shared caches. Both of these often
support manual cashing validation, either via an A p I or by allowing you to input
rules for invalidation next to being used for validating Akash item. There's
another interesting use case for e tax dealing with concurrency. That's what we
learn about in the next model. The last one off the course
Supporting Concurrency
Coming Up
[Autogenerated] How can we ensure that when two people are working on the same
resource? An update of the results by the first person no longer over rights to
change is the second person made. In the meantime, that's what we're going to deal
with in this module supporting concurrency. I'm Kevin and I'll guide you through
it. This model is all about concurrency. We'll start by looking into an example of
how we can support concurrence in arrest for world afterwards will dive into a demo
in which will again use E tax to correctly support us. Let's dive in.
Summary
[Autogenerated] the eat acts we used for validation can also be used as a token or
validator for an optimistic concurrency strategy. This allows concurrent users to
work on the same resorts without running the risk of accidentally overriding a
newer version of the resource. For that, we or rather, the consuming application
sends the E tak if match Heather. If the attack doesn't match with heat like the
server generates for the resource the update will fail with a 4 12 precondition
failed. With that, this course is done. I hope you enjoyed watching it as much as I
enjoyed making it and recording it. But I'm not done yet. Before I go, I have four
more thing to say. You're ready to be awesome.