Making query strings agnostic
Under normal circumstances, Fastly would consider these URLs as different objects that are cached separately:
It is possible, however, to have them all ignore the query string and return the same cached file.
Log in the Fastly application and click the configure tab (wrench icon).
From the Service menu, select the appropriate service and then click the blue Configure button. The main controls for your selected service appear.
Click Content from the section list on the left.
In the Headers area, click the New button. The New Header window appears.
Fill out the New Header window as follows:
- Set the Name field to whatever you want (e.g., "Chop Off Querystring")
- Select Request from the Type menu.
- Select Set from the Action menu.
- In the Destination field type
- In the Source field type
- Select No from the Ignore If Set menu.
- Set the Priority field to whatever priority you want.
Click the Create button to create the new header. The new header you created appears in the list of headers on the Content page.
The request will be sent to the origin as a URL without the query string.
For more information about controlling caching, see our Cache Control Tutorial.