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:
| Duration | Seconds |
|---|---|
| 1 hour | 3600 |
| 1 day | 86400 |
| 1 week | 604800 |
| 1 month | 2592000 |
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:
mp4for video filesjpgfor JPEG imagescssfor stylesheets
5
Save the rule
Click Save Edge Rule to activate.
Examples
Cache video files for 30 days
| Setting | Value |
|---|---|
| Action | Override Cache Time |
| Cache Time | 2592000 (30 days) |
| Condition | File Extension |
| Extension | mp4 |
Cache images for 1 week
| Setting | Value |
|---|---|
| Action | Override Cache Time |
| Cache Time | 604800 (7 days) |
| Condition | File Extension |
| Extension | jpg |
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:| Setting | Value |
|---|---|
| Action | Override Cache Time |
| Cache Time | 0 |
| Condition | File Extension |
| Extension | html |
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:| Action | Description |
|---|---|
| Override Cache Time | Controls how long content is cached on bunny.net edge servers |
| Override Browser Cache Time | Controls the Cache-Control header sent to browsers |
Related
- Smart Cache - Default cache settings for your pull zone
- Trigger Path Setup - Alternative way to match files using wildcards
- Rule Ordering - Understand how multiple cache rules interact