0
0
Azurecloud~10 mins

CDN caching rules in Azure - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to set the default caching behavior in Azure CDN.

Azure
cdnEndpoint.DefaultCacheBehavior = new CacheBehavior { CacheDuration = TimeSpan.FromSeconds([1]) };
Drag options to blanks, or click blank then click option'
A60
B3600
C86400
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using 0 disables caching, which is not default.
Using very large values may cause stale content.
2fill in blank
medium

Complete the code to add a caching rule that bypasses caching for query strings.

Azure
cdnEndpoint.CachingRules.Add(new CachingRule { QueryStringCachingBehavior = [1] });
Drag options to blanks, or click blank then click option'
ABypassCache
BIgnoreQueryString
CUseQueryString
DCacheEveryQueryString
Attempts:
3 left
💡 Hint
Common Mistakes
Using IgnoreQueryString caches ignoring query strings, not bypassing.
UseQueryString caches based on query strings.
3fill in blank
hard

Fix the error in setting the cache duration to 2 hours in Azure CDN caching rule.

Azure
cachingRule.CacheDuration = TimeSpan.FromSeconds([1]);
Drag options to blanks, or click blank then click option'
A3600
B7200
C120
D14400
Attempts:
3 left
💡 Hint
Common Mistakes
Using 120 seconds equals 2 minutes, not 2 hours.
Using 3600 seconds equals 1 hour.
4fill in blank
hard

Fill both blanks to configure a caching rule that caches only if the request method is GET and the response status code is 200.

Azure
cachingRule.MatchConditions.Add(new RequestMethodCondition { Method = "[1]" });
cachingRule.MatchConditions.Add(new ResponseStatusCodeCondition { StatusCode = [2] });
Drag options to blanks, or click blank then click option'
AGET
BPOST
C200
D404
Attempts:
3 left
💡 Hint
Common Mistakes
Using POST method is not cacheable by default.
Using 404 status code caches error pages.
5fill in blank
hard

Fill all three blanks to create a caching rule that caches content for 30 minutes, ignores query strings, and caches only for GET requests.

Azure
var cachingRule = new CachingRule {
  CacheDuration = TimeSpan.FromSeconds([1]),
  QueryStringCachingBehavior = "[2]",
  MatchConditions = { new RequestMethodCondition { Method = "[3]" } }
};
Drag options to blanks, or click blank then click option'
A1800
BIgnoreQueryString
CGET
DBypassCache
Attempts:
3 left
💡 Hint
Common Mistakes
Using BypassCache disables caching for query strings.
Using POST method is not cacheable by default.