Cache-Control setting for dymanic pages with "?" in the URL

3 views
Skip to first unread message

HogeyScale

unread,
Mar 7, 2010, 12:32:11 PM3/7/10
to page-speed-discuss
Hi All,

We have a database driven website that uses ASP to generate the pages.
I works very well, but IIS sets the Cache-control to "private" by
default for ASP pages because they are "dynamic". We can override this
setting, but Page-Speed recommends setting the Cache-Control to
"private" for resources that have a "?" in the url. Our pages use
"?"'s in the urls, but everything after the "?" could be considered
static because the content almost never changes for those identifiers.

Here is an example:

http://www.my-website.com/products.asp?=widget1

http://www.my-website.com/products.asp?=widget2

These two url's use the same asp page "products.asp" which is dynamic,
but the information for widget 1 and widget 2 could be considered
static because the information for these products almost never change.
My question is, can we safely set Cache-Control to "public" for these
resources?

Thanks,
MWN

Billy Hoffman

unread,
Mar 7, 2010, 1:27:48 PM3/7/10
to page-speed-discuss
MWN,

It sounds like you can.

You should probably do 2 other things. First, use a rewriting engine to get rid of the query strings entirely. In other words convert /foo/products.asp?id=5 to /foo/products.asp/5/. You want to do this because most upstream caching proxies will not cache a resource if it has a query string, even if it has a cache-control:public header. (see http://www.stevesouders.com/blog/2008/08/23/revving-filenames-dont-use-querystring/)

Since you say the product pages don't change very often, I would also suggest hooking up the ASP pages to return a Last-Modified header as well. While this may help some of your visitors the big help will be to search engines. It will drastically cut the bandwidth they consume. You will have to plug this into your database somehow (as in, add timedate stamp column into your Products table. Whenever you do a SQL UPDATE on a product's row, either through the web app when someone adds a comment for that product or through a backend system where you manage the products in the database, you should update the timedate stamp. Then at the top of products.asp you could do something like:

IF Request.hasHeader("Last-Modified")
Then
productLastModified = getLastModifiedTimestampFromDB(ProductID)
IF (productLastModified <= Request.Headers("Last-Modified")
-- Return an HTTP 304
END IF
ENDIF
--Standard page handling logic here--

Make sense?

Take care,
Billy
--

--
You received this message because you are subscribed to the Google Groups "page-speed-discuss" group.
To post to this group, send email to page-spee...@googlegroups.com.
To unsubscribe from this group, send email to page-speed-disc...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/page-speed-discuss?hl=en.


Martian Guy

unread,
Jul 2, 2013, 7:19:49 PM7/2/13
to page-spee...@googlegroups.com, billym...@gmail.com
Hi Billy,

You said 'most upstream caching proxies will not cache a resource if it has a query string'. Do you know if page speed does that?

Regards,
MG
To unsubscribe from this group, send email to page-speed-discuss+unsub...@googlegroups.com.

Dave Mankoff

unread,
Jul 3, 2013, 2:25:49 PM7/3/13
to page-speed-se...@googlegroups.com, billym...@gmail.com
+page-speed-service-discuss
-page-speed-discuss

It doesn't answer the question exactly, but this may provide some insight: https://developers.google.com/speed/pagespeed/service/faq#cachewhat

The PSS folks will know more.



-dave mankoff


To unsubscribe from this group and stop receiving emails from it, send an email to page-speed-disc...@googlegroups.com.

To post to this group, send email to page-spee...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages