Search for last instance of word in a file

Hi

I'm trying to search for the last instance of the word 'cache' in a HTML file that I have downloaded from YouTube.
I'm using the following syntax, but an error is thrown when I try it.

grep -f "cache" 

Also I wish to append the above grep command to the below so that the search for cache is completed as part of the below script.

vidid=$(sed -n "/fmt_url_map/{s/[\'\"\|]/\n/g;p}"  $file > youtube3.html)

Thanks
Colm

grep " cache" <infile | tail -1

will show last line that matches criteria

Does the '<infile' relate to the file I wish to pipe it into ?

while read -r LINE
do
  case "$LINE" in
      "cache" ) var=$LINE;;
  esac
done < "myfile"
echo $var