midudev GitHub avatar

query-http-demo

midudev

A demo Express application showcasing the proposed HTTP QUERY method (RFC 10008) that combines the safety and cacheability of GET with the body-carrying ability of POST for complex, cacheable queries.

Stars

38

7-day growth

No data

Forks

7

Open issues

0

License

No data

Last updated

2026-06-26

AI repository intelligence
FR-AI / ANALYSIS

Why it is worth attention

It addresses a long-standing pain point in API design—making filter/search endpoints that are both expressive (JSON body) and cacheable (like GET)—by implementing the new QUERY method and comparing it side-by-side with GET and POST.

Who it is for

  • Backend developers designing REST APIs for search/filter endpoints
  • Node.js/Express developers curious about HTTP protocol evolution
  • API architects evaluating caching strategies for read-only queries
  • Developers interested in upcoming HTTP standards and RFCs

Use cases

  • Replacing POST-based search APIs with cacheable QUERY to improve performance and reduce database load
  • Implementing complex filtering with nested JSON objects while keeping responses cacheable by CDNs and proxies
  • Demonstrating the limitations of GET query strings and justifying the adoption of QUERY in internal or external APIs

Strengths

  • Provides a clear, fair three-way comparison (GET, POST, QUERY) with identical filtering logic and caching headers
  • Includes a working Express 5 server with in-memory cache, TTL, and X-Cache headers to verify behavior
  • Offers multiple testing interfaces: browser UI, curl commands, REST Client requests, and an automated demo script
  • Explains the technical rationale thoroughly, including URL length limits, encoding issues, and logging risks

Considerations

  • Client-side browser support for QUERY in fetch is not yet universal; the demo includes a try/catch fallback
  • Browser HTTP cache currently only caches GET/HEAD; server-side caching works but CDN caching is still evolving
  • Requires Node 26 or higher and Express 5; not compatible with older Node.js versions or Express 4

README quick start

QUERY · el nuevo método HTTP (RFC 10008)

Demo en Express del mismo endpoint servido con GET, POST y el nuevo método QUERY, para ver de un vistazo qué aporta y por qué importa la caché.

QUERY acaba de pasar a Proposed Standard. La idea en una frase:

QUERY = la seguridad y la cacheabilidad de GET + la capacidad de mandar un body de POST.

  • ✅ Como GET: es un método seguro (no modifica el recurso) → la respuesta se puede cachear.
  • ✅ Como POST: puede llevar body, así que mandas un JSON con filtros complejos.
  • ✅ Lo que ninguno de los dos te da solo: mandar un JSON Y poder cachear la respuesta.

Enlaces:


El problema: GET vs POST para filtrar datos

Imagina un buscador de productos con filtros: categorías, rango de precio, rating, orden…

Opción A — GET con query string

GET /api/products/search?categories=laptop,phone&priceMin=800&priceMax=1500&minRating=4.5&sortBy=price&sortOrder=desc
  • 👍 Es cacheable por defecto (navegador, CDN, proxies).
  • 👎 Todo es texto: hay que castear números y booleanos a mano en el server.
  • 👎 Los filtros complejos o anidados (un array de objetos, condiciones OR/AND) no caben bien en una URL.
  • 👎 Límite de longitud de URL y los parámetros acaban en logs (peor para datos sensibles).

¿Cuánto puede llegar a medir una URL en GET? (límites reales)

No hay un límite único universal.

A nivel de estándar HTTP, no se define una longitud máxima estricta para una URI. Lo que sí recomienda RFC 9110 es que clientes y servidores soporten al menos 8000 octetos en URIs dentro de elementos del protocolo.

En la práctica:

ContextoLímite recomendable
Máxima compatibilidad≤ 2.000 caracteres
Apps modernas controladas≤ 8.000 bytes aprox.
Sitemap SEO≤ 2.048 caracteres por URL
Apache por defecto8190 bytes en la request line
Nginx por defectoalrededor de 8K para la request line, según buffer

Mi recomendación práctica:

Description

Mismo endpoint con GET, POST y el nuevo método HTTP QUERY (RFC 10008) en Express

Related repositories

Similar projects matched by category, topics, and programming language.

ddosi
Featured
ddosi GitHub avatar

PacketLens

PacketLens is a pure front-end, offline pcap analysis tool that runs entirely in the browser, supporting deep protocol decoding, HTTPS decryption, and million-packet instant loading without any backend.

HTML
19
ViffyGwaanl
Featured
ViffyGwaanl GitHub avatar

kimi-k3-learn

An interactive learning system that turns the 47-page Kimi K3 technical report into a single offline HTML file with running algorithms, 3D visualizations, spaced repetition quizzes, and a smart highlighting QA tool.

AI & Machine Learning
15
iamtechartist
Featured
iamtechartist GitHub avatar

human-cell-visualizer

An interactive 3D visualization of three human cell types using Three.js, WebGL particles, and custom GLSL shaders, allowing users to rotate, zoom, morph, and explore annotated structures.

Design & Creative
13