Bypassing Cache by User Agent
Sometimes you want certain tools to always get a freshly built page, never a cached one. The Bypass User Agents setting lets you do that by matching the visitor’s browser identification string.
What this does
Every request includes a User-Agent string that identifies the browser or tool making it. When you add a value to Bypass User Agents, any request whose User-Agent contains that text skips the cache and gets a freshly built page.
This is useful for tools that should always see the live page, such as:
- Screenshot bots
- Internal previews
- Monitoring services
Settings explained
| Setting | What it does | Default |
|---|---|---|
| Bypass User Agents | Requests from matching User-Agents skip the cache | Empty |
By default this list is empty, so no User-Agents are bypassed. You add only the ones you want.
Matching is a substring check. A value matches if it appears anywhere in the visitor’s User-Agent string. Glob patterns (*, ?, [ ]) and raw regex (with a ~ prefix) are also supported, the same as the other exclusion settings.
Tip: Substring matching is usually all you need here. User-Agent strings vary a lot, so a short, distinctive piece of text is the most reliable thing to match.
How to set it up
- Open the xSpeed Cache Cache page in your WordPress admin.
- Find the Bypass User Agents setting.
- Add one value per line. Each value is a piece of text to look for in the User-Agent.
- Save your settings. Saving purges the cache so the rule applies.
Best practices
- Add only the tools you actually need to bypass. Keeping the list short avoids accidentally bypassing real visitors.
- Use a distinctive substring from the tool’s User-Agent rather than the whole string.
- This is for tools, not for regular visitors. Bypassing common browsers would defeat the purpose of caching.
Troubleshooting
- A monitoring tool reports the wrong page. Add a distinctive piece of its User-Agent string to Bypass User Agents so it always gets a freshly built page.
- My cache hit rate dropped. Check that a bypass value is not matching ordinary visitors. Make the value more specific.
FAQ
Is the match case-sensitive? No. The substring check ignores case.
Can I use patterns instead of plain text?
Yes. Glob patterns and ~ raw regex are supported, but a plain substring is usually the simplest choice.
Related
- How to Enable Page Cache
- Excluding Pages, URLs, and Cookies from Cache
- Separate Mobile Cache