I need to write a script which Warm up the Application Cache with the website Pages when my server restarts so that when a User visits the website, the pages will be served from Cache leading to a better response time.

Can someone help me writing a script to warm up the Cache with those pages using a bash script please? I have been thinking of using wget command to load the URL but not sure if that is the correct approach? I have come up to the below code till now. Any help is appreciated.

#!/bin/bash input="/home/testadmin/url.txt" while IFS= read -r line do echo Refreshing $line wget --no-check-certificate --no-cache "$line" #time wget -pq --no-check-certificate --no-cache --delete-after "$line" #curl -s -w %{time_total}\\n -o /dev/null "$line" done < "$input"

  • webmasters.stackexchange.com might have more webserver experts, but if you're asking how to write a script on a UNIX/Linux system, you're on-topic here. From the sounds of the current question, it seems your question is more around whether retrieving those URLs would appropriately load the cache; is that correct? – Jeff Schaller Jul 12 at 16:35
  • Hi Jeff, yes so this is what I have created till now. My requirement is basically to Warm up or load the server cache when the server restarts so that Pages can be served quickly. This is what I have written till now. Is that correct? #!/bin/bash input="/home/testadmin/url.txt" while IFS= read -r line do echo Refreshing $line wget --no-check-certificate --no-cache "$line" #time wget -pq --no-check-certificate --no-cache --delete-after "$line" curl -s -w %{time_total}\\n -o /dev/null "$line" done < "$input" – Shashank Agrawal Jul 15 at 8:38
  • Comments, as you've seen, have limited formatting; please edit your current script into your question so that Answerers know where you're starting from. Thank you! – Jeff Schaller Jul 15 at 9:43
  • The place to edit your question is here – Jeff Schaller Jul 15 at 10:15
  • Thanks Jeff. I have edited my question with the Code – Shashank Agrawal Jul 15 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.