Does Cloudflare cache external resources like scripts?

Hello,

If I activate - Caching Level: Ignore query string

Will external scripts, CSS, and requests get cached? (I don’t want them to be cached)

Example: Below request - Will it get cached?

https://www.google.co.in/ads/ga-audiences?v=1&aip=1&t=sr&_r=4&tid=UA-84412-1&cid=866734497.1570963167&jid=1848684089&_v=j79&z=1768358822&slf_rd=1&random=4286912088

No, anything not going through Cloudflare wont be cached.

1 Like

No, anything not going through Cloudflare won’t be cached.” - ok, thanks. This is what I wanted.


I’ve activated - Caching Level: Ignore query string

But it doesn’t strip https://example.com/post-about-health/?_gl=15672wtyfc to https://example.com/post-about-health/

[https://example.com/post-about-health/?_gl=15672wtyfc - This is the page visited from a link. But it should redirect (or ignore) to https://example.com/post-about-health/]

But how can I achieve this?

It wont strip the query string, it simply wont take it into consideration for caching.

If you want to strip the query string you could probably achieve this with a redirecting page rule of that sort

*domain.com/*?* -> $1domain.com/$2

Untested of course.

I have used all my free 3 page rules.

Can I configure it with .htaccess? There is no disadvantage in choosing .htaccess over pagerule, right?

In that case you could purchase more page rules.

If that is not possible you could probably also achieve that via .htaccess, however that would be a question for StackExchange then.

in theory it will be sligly slower because:

in htaccess request flow:

cloudflare -> origin server(htaccess) -> cloudflare -> redirect

vs pagerule:

cloudflare -> redirect

nothing I will worry about unless you have good reason to be worried.

the other question is why do you want to redirect when there is query string? what are you trying to solve? maybe you are looking for the

rel=“canonical”

I’m using Google’s AMP. The AMP pages are served from Google’s server.

The AMP pages have links to my non-AMP pages.

But when the visitors come through those links, it adds something like ?_gl=1*um0ntk*_ga*YW1wLUVyYS1QbHgwcFp1SEJBYVlGSlNYdWNQUWI

This affects some functionality of my site. So I want to remove/redirect it.

Example:

https://example1.com/any-path-here/?_gl=1*um0ntk*_ga*YW1wLUVyYS1QbHgwcFp1SEJBYVlGSlNYdWNQUWIxNGVxY2VhakRDNDUtYmJUZWZPV1M2WEdWN2s2dXVRNzNZWGNTdkk

should redirect to

https://example1.com/any-path-here/

Only the _gl= seems to be constant. After that alphanumeral characters and symbols are there (which changes for every url). Which has to be removed, from the string query.

I have tried:

    <IfModule mod_rewrite.c>
    RewriteEngine On  
    RewriteCond %{QUERY_STRING} _gl=    
    RewriteRule ^ %{REQUEST_URI}? [L,R]
    </IfModule>

And

    <IfModule mod_rewrite.c>
    RewriteEngine On  
    RewriteCond %{QUERY_STRING} ^_gl=*    
    RewriteRule ^ %{REQUEST_URI}? [L,R]
    </IfModule>

And other rules. But nothing seems to work.

Unfortunately that would be an Apache specific question and is better suited for aforementioned forums like StackExchange. Though I am pretty sure somebody had already tried that before, so I’d expect an online search to return something as well.

Yeah this is off topic. Online search didn’t help. Hope I will get help somewhere.

Ehm, https://www.google.com/search?client=firefox-b-d&q=apache+strip+query+string

Those questions seems to answer simple defined redirect

For example:

I want to redirect from:

www.example.com/ca/blog/?lang=ca  

to

www.example.com/ca/blog/

Answer:-

You can use this rule in your root .htaccess:

RewriteEngine On

RewriteCond %{QUERY_STRING} ^lang= [NC]
RewriteRule ^(ca/blog/?)$ %{REQUEST_URI}? [NC,L,R=301]

But my path is

?_gl=1um0ntk_ga*YW1wLUVyYS1QbHgwcFp1SEJBYVlGSlNYdWNQUWIxNGVxY2VhakRDNDUt

So
RewriteCond %{QUERY_STRING} ^?_gl= [?] The Regular expression for match anything is (.*) , [\s\S]* , $ ,

But nothing seems to work.

I am not quite sure how your query string is different from the examples in the provided link, but anyhow, we really are beyond the forum’s scope at this point. I am quite sure StackExchange will eventually have the right answer to your use case.

My link changes after ?_gl=Afterthis-the-char-varies-with-symbols-numbers-etc

I fixed the problem. I just had to move my existing redirect rule to the top.

This topic was automatically closed after 14 days. New replies are no longer allowed.