Packets are chunks of information send to a client or server. There are many types, but the main 2 are TCP and UDP. Usually web programmers do not have to touch these as these are handled at the OS level.
TCP stands for Transmission Control Protocol and is the most common packet type. Each packet has headers that include information on the range of bytes included of the total response payload. This information is required because packets are not sent and received chronologically, that would be super slow. If a server is sending to a client, it is the clients responsibility to stitch each packet together based on this information.
The client also sends back a message to the server saying it successfully received a packet. This allows the server to retry packets that fail to deliver (say, from network interference). It attempts a resend after a period of time (timeout). If, however, 2 identical packets were received, the client would just disregard one as it will know, again, based on the headers, the data it already has.
UDP stands for User Datagram Protocol. UDP is unreliable as clients do not send back ‘ok’ messages and therefore, there is no attempt from the server to resend. UDP packets also only have a checksum of 16 bits - hardly secure in this day and age!
So if TCP is reliable and safe, while UDP isn’t, why would one decide to use UDP? Speed. So for applications that need data as quickly as possible such as multiplayer gaming, UDP may be considered.