powered-cache icon indicating copy to clipboard operation
powered-cache copied to clipboard

Cache Exclusion Based on HTTP Referer

Open mustafauysal opened this issue 1 year ago • 1 comments

Description

Introduce a feature to exclude caching based on the value of the HTTP_REFERER header, similar to the existing functionality for cookie-based cache exclusion. This would allow users to define rules that bypass caching for requests originating from specific referers.

Use Case

Some users may want to exclude caching for certain pages or actions based on the referer. For example:

  • Dynamic content that should not be cached when accessed from specific sources.
  • Improved control over caching for scenarios involving redirections or traffic from external links.

Proposed Implementation

  1. Add a new setting under the Advanced Options section in the Powered Cache settings.
  2. Allow users to specify one or more referers (using strings or regular expressions).
  3. Modify the cache logic to check the HTTP_REFERER value and exclude caching if it matches any of the defined referers.

Example Configuration

  • User inputs:

    • Referer: example.com
    • Referer Regex: ^https://partner\.example\.com
  • Cache exclusion logic:
    Skip serving a cached page if $_SERVER['HTTP_REFERER'] matches any of the defined referer rules.

Benefits

  • Adds flexibility for users to manage caching behavior for specific scenarios.
  • Simplifies user workflows by eliminating the need for custom workarounds like cookies.
  • Expands the functionality of Powered Cache, making it more robust and versatile.

Additional Notes

  • Ensure backward compatibility with existing features.
  • Include clear documentation and examples in the plugin settings UI and support materials.
  • Provide a detailed changelog entry if implemented.

mustafauysal avatar Jan 05 '25 19:01 mustafauysal

This will be a unique feature. It will help filter malicious traffic from parsers and scanners...

Igor-Yworld avatar Jan 06 '25 05:01 Igor-Yworld

added in 3.6, closing this now.

mustafauysal avatar May 28 '25 10:05 mustafauysal