Please Help Me Get Started - No caching needed, no content returned, custom logging


#1

Can someone please point me in the right direction for this? Keep in mind I’ve never used Fastly before. Never used VCL before, etc. However as a software engineer I’m well acquainted with HTTP and how it works.

Here are my requirements:
I need to setup a fastly endpoint that will accept GET requests and always return “200 OK” as quickly as possible, with no body whatsoever. The sole purpose of the endpoint is to track users. The plan is to:
a) never allow intermediate hosts to cache the response
b) every time fastly gets a request, it will always send a syslog containing the query string and all of the request headers to our syslog server.
c) syslogs will be formatted as json. This seems appropriate: https://github.com/fastly/vcl-json-generate

Since we are never returning any content to the client, whether fastly “caches” the empty response is of no consequence, as long as it meets the requirements above (intermediate hosts never cache, browser never caches, and every fastly hit results in a syslog message sent to our syslog server).

(I’m aware that it probably sounds silly to use Fastly at all for this. However I didn’t design it, I’m only implementing it.)

Questions:
a) using vcl_log is a great idea, since it allows us to return a response to the client before sending the syslog (quick response is one of the goals). Since I’m going to use vcl-json-generate in “vcl_log”, I will need to upload custom VCL, is this correct?
b) is “vcl_log” called after every request, regardless of cache status?
c) no origin server is necessary. Is it even possible to set up a Fastly endpoint with no origin server?

Can you please point me in the right direction?


#2

Hi eddified-,

Yes, you can fully control how Fastly serves the cache to the client through VCL.

To answer your question:

a) Yes, vcl_log will be executed after the content is delivered through vcl_deliver.
If you want to utilize vcl-json-generate for the logging, you will need to do either VCL snippets or custom VCL. However, I’d recommend setting up the syslog from Logging tab on Fastly UI.

b) Correct - unless you attach a condition to the logging.

c) Yes, you can implement originless service through Fastly.
You can serve the custom HTML response from the edge. As you mention always 200 OK with no content, I’d suggest working around with synthetic response. If you select 200 OK and don’t attach any condition to the custom response, it will always return 200 with no content to the client.

If you need more specific supports for logging or custom responses, please feel free to reach out to us at support@fastly.com.

Best,
Hiro