Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Get started
HTTP Caching and SSL Basics
00:00
5 left

HTTP Caching and SSL Basics

MediumSQL · PostgreSQL

Problem

Explain how SSL certificates and HTTP cache headers affect a web service in production.

Using the provided service, certificate, cache-header, and request tables, write a query that summarizes these production effects for each service as of 2025-03-08.

Output

  1. One row per service, including services without matching certificate, cache, or request records.
  2. Return service_name, endpoint, certificate_status, cache_policy, request_count, average_response_ms, and cache_hit_rate_percent.
  3. Classify certificates as valid, expiring, expired, or missing, and cache policies as revalidatable, cacheable, no-cache, or missing.
  4. Include requests from 2025-03-01 through 2025-03-08, and order by endpoint ascending.

Output details

  • Treat certificate expiration before 2025-03-08 as expired, and expiration through 2025-04-07 as expiring; classify later certificates as valid.
  • Use only certificates where is_current is true, retaining multiple matching current certificates as separate output rows.
  • Match cache headers captured exactly on 2025-03-08; classify missing headers or NULL max_age_seconds as missing, zero as no-cache, true etag_present as revalidatable, and others as cacheable.
  • Treat the request interval as inclusive of 2025-03-01 and exclusive of 2025-03-09.
  • Round average_response_ms and cache_hit_rate_percent to two decimal places, return NULL metrics without requests, and count only requests with cache_hit true as hits.
  • Preserve the reference's unspecified database order when endpoint values tie, without applying a secondary sort key.

Schema

web_services
ColumnTypeDescription
service_idPKINTUnique service identifier
service_nameVARCHAR(100)Service display name
endpointVARCHAR(150)HTTP endpoint path
ssl_certificates
ColumnTypeDescription
cert_idPKINTUnique certificate identifier
service_idINTReferenced service
issued_atDATECertificate issue date
expires_atDATECertificate expiration date
tls_versionVARCHAR(20)Negotiated TLS version
is_currentBOOLEANWhether this is the active certificate
http_cache_headers
ColumnTypeDescription
header_idPKINTUnique header observation
service_idINTReferenced service
captured_atDATEDate headers were captured
cache_controlVARCHAR(100)Observed Cache-Control header
max_age_secondsINTMaximum cache lifetime in seconds
etag_presentBOOLEANWhether an ETag header was present
service_requests
ColumnTypeDescription
request_idPKINTUnique request identifier
service_idINTReferenced service
requested_atDATERequest date
status_codeINTHTTP response status code
response_msDECIMAL(10,2)Response latency in milliseconds
cache_hitBOOLEANWhether the response was served from cache
Tablesweb_servicesssl_certificateshttp_cache_headersservice_requests
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the four tables are in the Question tab.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.