Prevent caching of file outside of domain

I could be miles off base here, but all of my sites have a CGI script that accesses a shared LIB file that’s stored on the server’s /home/ directory; ie, not www accessible.

The CGI script is a general contact form processor, and I use that LIB file to block common spam.

Since using Cloudflare, I added these two lines:

  exists($ENV{'HTTP_CF_IPCOUNTRY'}) &&

I’m constantly getting this error, though:

Bad name after HTTP_CF_IPCOUNTRY' at /home/filter.lib

I’ve rewritten it a million times and ran it through emulators to ensure that the syntax is right, so eventually I gave up and just commented those lines out.

But I’m still getting the error!! :open_mouth:

All of my sites include this Cache rule:

(starts_with(http.request.uri.path, "/cgi-bin"))
Bypass cache

I can’t think of any reason why I’m still getting this error in my log, UNLESS Cloudflare is caching the filter.lib file?

If that’s the case, how do I tell it to not cache this file?

The “Bad name after” Perl error usually results from a syntax error, in particular a missing single-quote closing a string somewhere before the reported error. It’s seeing the single-quote at the end of your string as an opening quote instead of a closing quote. Since the error isn’t actually in the code at the point where it’s being reported, but rather somewhere before it, deleting that code won’t necessarily fix it.

Enable use strict and use warnings in your script, and check your syntax to make sure all of your strings are properly quoted. Using an editor with syntax highlighting is invaluable in this regard.

1 Like

I’ve been coding Perl for darn near 30 years, and I’m super embarrassed by the solution! LOL

This particular script was wrapped in eval ' '; just in case I coded an error, and I needed the main script to run anyway. For testing I was removing the eval, and was then unable to duplicate the error. Which is why I thought it was a caching issue.

But OF COURSE, now I see that the issue was the danged single quote for eval! The script was seeing the first ’ in the $ENV as closing the eval, so of course the rest of it was an error.

Sorry that I blamed Cloudflare! LOL


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