Skip to content
v2.275.0

CacheControl Class ​

Used for HTTP cache-control header, which influences downstream caches.

Example ​

ts
declare const destinationBucket: s3.Bucket;
new s3deploy.BucketDeployment(this, 'BucketDeployment', {
  sources: [s3deploy.Source.asset('./website', { exclude: ['index.html'] })],
  destinationBucket,
  cacheControl: [
    s3deploy.CacheControl.maxAge(Duration.days(365)),
    s3deploy.CacheControl.immutable(),
  ],
  prune: false,
});

new s3deploy.BucketDeployment(this, 'HTMLBucketDeployment', {
  sources: [s3deploy.Source.asset('./website', { exclude: ['*', '!index.html'] })],
  destinationBucket,
  cacheControl: [
    s3deploy.CacheControl.maxAge(Duration.seconds(0)),
  ],
  prune: false,
});

Properties ​

valueanyvalueAnyvalueObjectValueobjectValueinterface{}#
The raw cache control setting.

Methods ​

fromString(s: string): CacheControl // chainable@staticmethod def from_string(s: str) -> CacheControlpublic static CacheControl fromString(String s)public static CacheControl FromString(string s)func FromString(S *string) CacheControlstatic#
Constructs a custom cache control key from the literal value.
immutable(): CacheControl // chainable@staticmethod def immutable() -> CacheControlpublic static CacheControl immutable()public static CacheControl Immutable()func Immutable() CacheControlstatic#
Sets 'immutable'.
maxAge(t: Duration): CacheControl // chainable@staticmethod def max_age(t: Duration) -> CacheControlpublic static CacheControl maxAge(Duration t)public static CacheControl MaxAge(Duration t)func MaxAge(T Duration) CacheControlstatic#
Sets 'max-age=<duration-in-seconds>'.
mustRevalidate(): CacheControl // chainable@staticmethod def must_revalidate() -> CacheControlpublic static CacheControl mustRevalidate()public static CacheControl MustRevalidate()func MustRevalidate() CacheControlstatic#
Sets 'must-revalidate'.
mustUnderstand(): CacheControl // chainable@staticmethod def must_understand() -> CacheControlpublic static CacheControl mustUnderstand()public static CacheControl MustUnderstand()func MustUnderstand() CacheControlstatic#
Sets 'must-understand'.
noCache(): CacheControl // chainable@staticmethod def no_cache() -> CacheControlpublic static CacheControl noCache()public static CacheControl NoCache()func NoCache() CacheControlstatic#
Sets 'no-cache'.
noStore(): CacheControl // chainable@staticmethod def no_store() -> CacheControlpublic static CacheControl noStore()public static CacheControl NoStore()func NoStore() CacheControlstatic#
Sets 'no-store'.
noTransform(): CacheControl // chainable@staticmethod def no_transform() -> CacheControlpublic static CacheControl noTransform()public static CacheControl NoTransform()func NoTransform() CacheControlstatic#
Sets 'no-transform'.
proxyRevalidate(): CacheControl // chainable@staticmethod def proxy_revalidate() -> CacheControlpublic static CacheControl proxyRevalidate()public static CacheControl ProxyRevalidate()func ProxyRevalidate() CacheControlstatic#
Sets 'proxy-revalidate'.
setPrivate(): CacheControl // chainable@staticmethod def set_private() -> CacheControlpublic static CacheControl setPrivate()public static CacheControl SetPrivate()func SetPrivate() CacheControlstatic#
Sets 'private'.
setPublic(): CacheControl // chainable@staticmethod def set_public() -> CacheControlpublic static CacheControl setPublic()public static CacheControl SetPublic()func SetPublic() CacheControlstatic#
Sets 'public'.
sMaxAge(t: Duration): CacheControl // chainable@staticmethod def s_max_age(t: Duration) -> CacheControlpublic static CacheControl sMaxAge(Duration t)public static CacheControl SMaxAge(Duration t)func SMaxAge(T Duration) CacheControlstatic#
Sets 's-maxage=<duration-in-seconds>'.
staleIfError(t: Duration): CacheControl // chainable@staticmethod def stale_if_error(t: Duration) -> CacheControlpublic static CacheControl staleIfError(Duration t)public static CacheControl StaleIfError(Duration t)func StaleIfError(T Duration) CacheControlstatic#
Sets 'stale-if-error=<duration-in-seconds>'.
staleWhileRevalidate(t: Duration): CacheControl // chainable@staticmethod def stale_while_revalidate(t: Duration) -> CacheControlpublic static CacheControl staleWhileRevalidate(Duration t)public static CacheControl StaleWhileRevalidate(Duration t)func StaleWhileRevalidate(T Duration) CacheControlstatic#
Sets 'stale-while-revalidate=<duration-in-seconds>'.