realrasengan / autobahn

automatic Hacker News front page output in terminal
MIT License
15 stars 5 forks source link

curl cache #3

Closed gabrielsroka closed 5 years ago

gabrielsroka commented 5 years ago

curl seems to cache the results on my Ubuntu VM. do you see this, too? any way to bust the cache?

i ported it to PowerShell (which is also MIT licensed) and ran it on Ubuntu. it doesn't seem to cache...

#!/snap/bin/pwsh

$total = 25
$url = "https://hacker-news.firebaseio.com/v0"
$stories = Invoke-RestMethod "$url/topstories.json"
for ($i = 1; $i -le $total; $i++) {
    $story = $stories[$i - 1]
    $item = Invoke-RestMethod "$url/item/$story.json"
    if ($i -lt 10) {
        $n = "$i) "
    } else {
        $n = "$i)"
    }
    Write-Host $n $item.title "|" $item.url
    Write-Host "    https://news.ycombinator.com/item?id=$story |" $item.by "|" $item.score -ForegroundColor DarkYellow
}

image

realrasengan commented 5 years ago

Sorry about that. I added '-H 'Cache-Control: no-cache'' to the curl invocation. Powershell HN looks great! Feel free to make a pull request with the pwsh implementation if you like!