Skip to content

Cache Exclusion Based on HTTP Referer #150

Closed

Description

@mustafauysal

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.

Activity

  1. self-assigned this
    on Jan 5, 2025
  2. Igor-Yworld commented on Jan 6, 2025

    @Igor-Yworld

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

  3. mustafauysal commented on May 28, 2025

    @mustafauysal
    MemberAuthor

    added in 3.6, closing this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions