Skip to main content
Edge Rules make it easy to customize cache times based on file extensions. This is useful when different content types need different caching strategies—for example, caching video files longer than HTML pages.

Use cases

  • Cache static assets (images, CSS, JS) for longer periods
  • Set shorter cache times for dynamic content
  • Cache video files for extended periods to reduce origin load
  • Override default cache behavior for specific file types

Configuration

1

Open Edge Rules

Navigate to your pull zone and select Edge Rules from the side menu.
2

Add a new rule

Click Add Edge Rule to create a new rule.
3

Select the Override Cache Time action

Choose Override Cache Time as the action.Enter the desired cache time in seconds:
DurationSeconds
1 hour3600
1 day86400
1 week604800
1 month2592000
4

Add a File Extension condition

Click Add Condition and select File Extension as the condition type.Enter the extension you want to match (without the dot). For example:
  • mp4 for video files
  • jpg for JPEG images
  • css for stylesheets
5

Save the rule

Click Save Edge Rule to activate.

Examples

Cache video files for 30 days

SettingValue
ActionOverride Cache Time
Cache Time2592000 (30 days)
ConditionFile Extension
Extensionmp4

Cache images for 1 week

SettingValue
ActionOverride Cache Time
Cache Time604800 (7 days)
ConditionFile Extension
Extensionjpg
Create separate rules for each file extension, or use multiple conditions with Match Any to apply the same cache time to multiple extensions.

Bypass cache for HTML files

To prevent caching of HTML files entirely:
SettingValue
ActionOverride Cache Time
Cache Time0
ConditionFile Extension
Extensionhtml
Setting cache time to 0 will bypass the edge cache if the content is not already cached. This increases origin load but ensures fresh content.

Multiple extensions

To apply the same cache time to multiple file types, you have two options:

Option 1: Multiple conditions (Match Any)

Add multiple File Extension conditions to a single rule and set the match type to Match Any:
  • Condition 1: File Extension = jpg
  • Condition 2: File Extension = png
  • Condition 3: File Extension = gif

Option 2: Separate rules

Create individual rules for each extension. This gives you more flexibility if you later need different cache times per extension.

Cache time vs Browser cache time

Edge Rules offer two cache-related actions:
ActionDescription
Override Cache TimeControls how long content is cached on bunny.net edge servers
Override Browser Cache TimeControls the Cache-Control header sent to browsers
You can use both together to have different cache durations at the edge vs in the browser.