Proxomitron Tips: Advanced Filters and Performance Tweaks
Overview
Proxomitron is a local web-filtering proxy that modifies HTTP(S) traffic using user-defined filters. These tips focus on advanced filter techniques and performance tweaks to reduce bandwidth, speed up browsing, and improve privacy and compatibility.
1. Organize filters for maintainability
- Use categories: Group filters by purpose (ads, tracking, layout fixes, scripts).
- Name consistently: Prefix rules with short tags (e.g., “AD-”, “TRK-”, “CSS-”) to find and edit quickly.
- Comment liberally: Add brief comments explaining why a rule exists and when it can be removed.
2. Prefer targeted rules over broad ones
- Match specific hosts/paths: Use host and path constraints to avoid unintended side effects.
- Limit regex scope: Anchor patterns (e.g., ^ and $) and use non-greedy quantifiers to reduce CPU use.
- Avoid blanket replacements: Rewriting large chunks of HTML/CSS can break pages and slow processing.
3. Optimize regular expressions
- Use atomic grouping and non-capturing groups: Replace (…) with (?:…) when you don’t need captures.
- Avoid excessive backtracking: Replace patterns like .?foo with more precise character classes (e.g., [^<]?).
- Test with sample pages: Validate regex performance on representative pages before enabling globally.
4. Block efficiently: prioritize and combine
- Order rules by cost: Put inexpensive hostname/path checks before expensive regex or script parsing.
- Combine similar blocks: Merge multiple simple host-block rules into one rule with alternation when safe.
- Use quick rejects: For known ad domains, return a small 1×1 GIF instead of processing full responses.
5. Use content-type checks
- Filter by MIME type: Apply heavy HTML/CSS/JS transformations only when Content-Type matches text/html, text/css, or application/javascript to avoid wasting CPU on images or binary downloads.
- Skip large responses: Set size thresholds to bypass transformations on very large responses (e.g., >1 MB).
6. Cache and reuse results
- Enable caching: Use Proxomitron’s caching for static resources to reduce repeated processing.
- Cache filter outputs: Where possible, cache the result of expensive rewrites keyed by URL and headers to reuse across requests.
7. Tackle scripts safely
- Block or rewrite trackers early: Remove known tracker scripts by host before executing complex DOM rewrites.
- Prefer blocking over modification: If a script only tracks, blocking it reduces CPU compared to rewriting it.
- Use minimal script edits: When modifying JS, change only the necessary tokens or function calls to avoid introducing errors.
8. Optimize CSS and layout fixes
- Use concise selectors: Target elements by ID or class rather than long selector chains.
- Prefer hiding over removal: Using simple display:none rules is faster and safer than reconstructing HTML.
- Batch style injections: Inject a single
9. Monitor performance and errors
- Enable detailed logging temporarily: Track slow rules and exceptions, then revert to minimal logging.
- Measure per-rule latency: Identify hotspots and optimize or disable rules causing delays.
- Use test profiles: Create a performance profile with only essential filters to compare baseline speeds.
10. Maintain compatibility
- Whitelist critical domains: Bypass or relax filters for payment gateways, banking, or other sensitive services.
- Use site-specific exceptions: Create targeted exceptions rather than disabling entire categories.
- Keep backups: Save filter sets before large changes to revert quickly if pages break.
Example: Efficient ad-blocking filter (concept)
- Host match: ads.example.com OR doubleclick.net
- Content-Type: text/html, application/javascript
- Action: return 1×1 GIF for requests under 50 KB; otherwise block headers with 204 No Content.
Final checklist
- Group and comment rules
- Target matches precisely
- Optimize regexes and order rules by cost
- Use content-type and size checks
- Cache outputs where possible
- Monitor and profile performance
- Maintain targeted exceptions for compatibility
Following these guidelines will help you build robust Proxomitron filters that improve browsing speed, reduce resource use, and minimize page breakage.
Leave a Reply