How to prevent caching 302 redirects

Cache Level: Cache Everything
Edge Cache TTL: an hour
Origin Cache Control: Off

As we intentionally disabled Origin Cache Control I understand and accept that everything is cached regardless of headers set by application. But I don’t understand why redirects 302 (temporary) are included, and I don’t have any idea how to exclude them.

We use geo-localization, entering the page https://example.com from England redirects to http://example.com/en but when I do the same from a different country I am still redirected to en. It is not an issue related to the home page, as it works also for subpages, so I can’t use the Cache Rule and just exclude https://example.com.

I was hoping for a Rule like (http.status_code eq "302") then Bypass cache, but I don’t see any such option. Any idea?

You can’t exclude by status code with a Page Rule, but you can with a Cache Rule — which also gives you a lot more flexibility as to what to cache.

1 Like

Yes, this module gives flexibility, so now please advise me, on how to exclude redirects or better - redirects with 302 status.

Hit the Create Rule button and under Edge TTL you should see a bunch of options, including Status Code TTL. Set 302 with either “no-cache” or “no-store”. You should find online resources that explain the difference between the two.

2 Likes

Are you sure you wanted to downvote that response? That’s not exactly very kind towards someone volunteering his time.

2 Likes

As I understand You suggest something like this:

The rule that covers all URLs (I don’t see other options like “any url”), moving Edge TTL from Page Rules to the Cache Rules, and adding an exception?

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.