FSharp.Data icon indicating copy to clipboard operation
FSharp.Data copied to clipboard

[HtmlProvider] How to Cache a request made by .Load(url)

Open eduardogoncalves opened this issue 5 years ago • 0 comments

How can I cache a request made using .Load() so on the second request to same page, the result is loaded from cache?

#1st request to /api/v1/carousel
JsonResult(HtmlDocument.Load("https://www.saibatudomt.com.br/").CssSelect(".stmt-block-larger.carousel").CssSelect("a")
            |> Seq.choose (fun x -> 
                x.TryGetAttribute("href")
                |> Option.map (fun a -> x.DirectInnerText(), a.Value())
            ))
#2nd request to /api/v1/mixed
JsonResult(HtmlDocument.Load("https://www.saibatudomt.com.br/").CssSelect(".duas-colunas .stmt-block-mixed").CssSelect("a")
            |> Seq.choose (fun x -> 
                x.TryGetAttribute("href")
                |> Option.map (fun a -> x.DirectInnerText(), a.Value())
            ))

eduardogoncalves avatar Jan 20 '20 01:01 eduardogoncalves