---
title: "How to make Varnish ignore a URL's query string for front-end application use"
date: "2022-03-08T00:26:52+00:00"
summary:
image:
type: "article"
url: "/acquia-cloud-platform/help/93361-how-make-varnish-ignore-urls-query-string-front-end-application-use"
id: "75d295ea-dcce-4025-aa53-785c33b4a572"
---

Table of contents will be added

Scenario
--------

You have a front-end (e.g. Javascript) application that responds on a specific endpoint/URL and reads/writes arguments from the URL for its logic/state. Since the logic is executed on the front-end, you want the page to be served from Varnish (regardless of arguments) as there is no need to make a request to the back-end for each variation of the URL.

For the purposes of this example let's say the endpoint/URL is /myapp

Problem
-------

    /myapp
    /myapp?arg1=value1
    /myapp?arg1=value1&arg2=value2

... will all be needlessly cached as different entries in Varnish, after having needlessly hit the back-end once, and when

    /myapp?arg1=value1&arg2=value2&arg3=value3

comes along, the same will happen. What we want is for Varnish to "ignore" everything after /myapp

Solution
--------

Configure your front-end application to read/write the arguments as a URI fragment instead of GET request arguments.

That is, replace the first "?" with "#" making the previous requests look like:

    /myapp
    /myapp#arg1=value1
    /myapp#arg1=value1&arg2=value2
    /myapp#arg1=value1&arg2=value2&arg3=value3

With this URL structure all the above pages would be cached/served as a single entry in Varnish as browsers will not send the URI fragment to the server.