Sometimes you can use both words for the same object, but they will have different meanings: E.g. When talking about a sheet of paper, you can say: "Ich schreibe bis an den Rand des Papiers", meaning that you are writing up to the end of the surface of the sheet. But then you can say: "Ich habe mich an der Kante des Papiers geschnitten", you have injured yourself at the sharp edge of the sheet.
"the edge of town" - der Stadtrand
"the edge of a cliff" - either "der Rand der Klippe" (emphasizing that the flat surface above ends somewhere) or "die Felskante" (focusing on the angle formed by the rock beneath your feet).
"the edge of a knife"? - either "die Klinge" (the blade) or "der Rcken des Messers" (the edge on the other side of the knife).