Cache certain pages on site for X minutes?

Comments

5 comments

  • Cassandra Dixon

    Q: Is it possible to have a general cache expiry for most pages and a defined expiry only for certain pages? if so how would we go about doing this?

    Yes, you can create cache setting rules within Fastly. Within the app go to Configure/Settings/Cache Settings. Select the New button to create a new caching rule.

    Example: Default Setting

    Name: Default Caching TTL: 86400 Stale TTL: 0 Action: N/A

    Example: Specific Caching

    ``` Name: Specific Path TTL: 300 Stale TTL: 0 Action: N/A or Deliver

    Then choose the gear icon and pick Condition. Add a condition to your caching rule. ```

    Here is a help guide example as well on overriding caching default based on backend responses . You would follow the same steps but your condition would be based on url path (req.url) or extension type (req.url.ext).

    Q: Also, does fastly have a cdn for images/js ?

    The Fastly service can serve for static (images/js/css) delivery, dynamic (acceleration from origin delivery), and content driven (static for a period of time) content. You can mange these assets in different services under your account. Each account can also have multiple domains/origins. Within each account you can create your caching rules and headers accordingly.

  • Trépanier,Jason

    [quote="cassandra, post:2, topic:433"] Then choose the gear icon and pick Condition. Add a condition to your caching rule. [/quote]

    hi Cassandra, thank you for the reply. I cannot find any documentation about conditions and how they work or anything. The only one I found was https://docs.fastly.com/guides/basic-configuration/overriding-caching-defaults-based-on-backend-responses and it shows beresp.status but does not list any parameters beyond 404 and 403

    What we want to do is cache mydomain.com/en/ for 1 minute, because the content is updated every minute and other pages can be cached for other time periods depending on update frequency on our end.

    Is there any documentation on the parameters available on how to do this somewhere?

    also, how do we get the images/js/css to be cached on Fastly instead of our server because our page on global.prod.fastly is showing that the resources are coming from our server (we didn't do cname/dns change yet, just trying out fastly)

    thank you

  • Cassandra Dixon

    Hi Jason,

    Our Conditions Tutorial provides a better breakdown of how to configure and use conditions in Fastly.

    In the your example:

    What we want to do is cache mydomain.com/en/ for 1 minute, because the content is updated every minute and other pages can be cached for other time periods depending on update frequency on our end.

    You can add a condition similar to the following on your caching rule:

    ``` Assumption: matching the URI path literally

    req.url == "/en/" || req.url == "/en"

    Assumption: matching the any URI path with "/en"

    req.url ~ "/en" ```

    With regards to your images/js/css file, run a test on your static file.

    1) Is the static domain(s) included in your Fastly configuration 2) When you test the file (since you haven't changed the cname), make sure to append the cname Example: curl -svo /dev/null http://www.image.com.global.prod.fastly.net/image_file 3) Check that the response does not have cache busting headers ( i.e Set-Cookie, Cache-Control:private)

  • Trépanier,Jason

    Hi Cassandra does Fastly offer service to help clients with configuration? We would gladly pay to have everything configured as we need it.

    Also, in the site I have configured I keep getting varnish cache errors randomly. I have not set any conditions or cache settings, only configured the base settings and while I can see the site on your domain, I often get a varnish error and in the control panel it shows that there were 77 errors. I don't know if I've done something wrong or its an error on your end with Varnish.

    To test your service, I also tried a load test and it had many errors loading the page on your site. Again, I don't know if I have the settings correct or its something on your end.

    If we would get everything configured the way we needed and the service reliably delivered our content to visitors, we would gladly sign up for paid services.

  • Trépanier,Jason

    Hi Cassandra

    After the forum post I sent an email to sales and they put me in touch with Tom . We are having a meeting this afternoon to discuss our needs

    Thanks for the fast replies

Please sign in to leave a comment.